Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大大大太阳yt
driver.js
提交
0aebd1a7
D
driver.js
项目概览
大大大太阳yt
/
driver.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
driver.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0aebd1a7
编写于
3月 04, 2018
作者:
K
Kamran Ahmed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add docs and allow modifying padding
上级
fe79342b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
16 deletion
+38
-16
.eslintrc.json
.eslintrc.json
+5
-2
README.md
README.md
+14
-0
assets/scripts/src/overlay.js
assets/scripts/src/overlay.js
+14
-12
assets/scripts/src/sholo.js
assets/scripts/src/sholo.js
+5
-2
未找到文件。
.eslintrc.json
浏览文件 @
0aebd1a7
...
...
@@ -9,7 +9,10 @@
"no-plusplus"
:
"off"
,
"no-cond-assign"
:
"off"
,
"func-names"
:
"off"
,
"no-param-reassign"
:
[
"off"
],
"max-len"
:
"off"
"no-param-reassign"
:
[
"off"
],
"max-len"
:
"off"
,
"no-multi-spaces"
:
"off"
}
}
\ No newline at end of file
README.md
0 → 100644
浏览文件 @
0aebd1a7
## spotlight-js
> Allows highlighting any element, adding feature introduction, adding hints
## Highlighting Single Elements
```
javascript
const
spotlight
=
new
Spotlight
({
opacity
:
0.7
,
// opacity for the background
padding
:
5
,
// padding around the element
});
spotlight
.
highlight
(
'
#some-element
'
);
spotlight
.
clear
();
```
\ No newline at end of file
assets/scripts/src/overlay.js
浏览文件 @
0aebd1a7
...
...
@@ -5,15 +5,17 @@ import Position from './position';
* cutting out the visible part, animating between the sections etc
*/
export
default
class
Overlay
{
constructor
({
opacity
=
0.75
})
{
this
.
opacity
=
opacity
;
this
.
overlayAlpha
=
0
;
this
.
positionToHighlight
=
new
Position
({});
this
.
highlightedPosition
=
new
Position
({});
this
.
redrawAnimation
=
null
;
this
.
highlightedElement
=
null
;
constructor
({
opacity
=
0.75
,
padding
=
5
})
{
this
.
opacity
=
opacity
;
// Fixed opacity for the layover
this
.
padding
=
padding
;
// Padding around the highlighted item
this
.
overlayAlpha
=
0
;
// Is used to animate the layover
this
.
positionToHighlight
=
new
Position
({});
// position at which layover is to be patched at
this
.
highlightedPosition
=
new
Position
({});
// position at which layover is patched currently
this
.
redrawAnimation
=
null
;
// used to cancel the redraw animation
this
.
highlightedElement
=
null
;
// currently highlighted dom element (instance of Element)
this
.
draw
=
this
.
draw
.
bind
(
this
);
this
.
draw
=
this
.
draw
.
bind
(
this
);
// To pass the context of class, as it is to be used in redraw animation callback
this
.
window
=
window
;
this
.
document
=
document
;
...
...
@@ -101,10 +103,10 @@ export default class Overlay {
// Remove the cloak from the position to highlight
this
.
removeCloak
({
posX
:
this
.
highlightedPosition
.
left
-
window
.
scrollX
-
5
,
posY
:
this
.
highlightedPosition
.
top
-
window
.
scrollY
-
5
,
width
:
(
this
.
highlightedPosition
.
right
-
this
.
highlightedPosition
.
left
)
+
(
5
*
2
),
height
:
(
this
.
highlightedPosition
.
bottom
-
this
.
highlightedPosition
.
top
)
+
(
5
*
2
),
posX
:
this
.
highlightedPosition
.
left
-
window
.
scrollX
-
this
.
padding
,
posY
:
this
.
highlightedPosition
.
top
-
window
.
scrollY
-
this
.
padding
,
width
:
(
this
.
highlightedPosition
.
right
-
this
.
highlightedPosition
.
left
)
+
(
this
.
padding
*
2
),
height
:
(
this
.
highlightedPosition
.
bottom
-
this
.
highlightedPosition
.
top
)
+
(
this
.
padding
*
2
),
});
if
(
canHighlight
)
{
...
...
assets/scripts/src/sholo.js
浏览文件 @
0aebd1a7
...
...
@@ -6,8 +6,11 @@ import './polyfill';
* Plugin class that drives the plugin
*/
export
default
class
Sholo
{
constructor
({
opacity
=
0.75
}
=
{})
{
this
.
overlay
=
new
Overlay
({
opacity
});
constructor
({
opacity
=
0.75
,
padding
=
5
}
=
{})
{
this
.
overlay
=
new
Overlay
({
opacity
,
padding
,
});
}
highlight
(
selector
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录