Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
L-Y.
driver.js
提交
9bf5661c
D
driver.js
项目概览
L-Y.
/
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 搜索 >>
提交
9bf5661c
编写于
3月 16, 2018
作者:
K
Kamran Ahmed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor resetting driver
上级
ca47107f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
19 deletion
+25
-19
demo/scripts/demo.js
demo/scripts/demo.js
+2
-0
src/core/overlay.js
src/core/overlay.js
+23
-19
未找到文件。
demo/scripts/demo.js
浏览文件 @
9bf5661c
...
...
@@ -110,11 +110,13 @@ document.addEventListener("DOMContentLoaded", function () {
document
.
querySelector
(
'
#animated-tour
'
)
.
addEventListener
(
'
click
'
,
()
=>
{
boringTourDriver
.
reset
();
animatedTourDriver
.
start
();
});
document
.
querySelector
(
'
#boring-tour
'
)
.
addEventListener
(
'
click
'
,
()
=>
{
animatedTourDriver
.
reset
();
boringTourDriver
.
start
();
});
...
...
src/core/overlay.js
浏览文件 @
9bf5661c
import
Position
from
'
./position
'
;
import
{
ANIMATION_DURATION_MS
,
CLASS_NO_ANIMATION
,
ID_OVERLAY
,
OVERLAY_HTML
}
from
'
../common/constants
'
;
import
{
createNodeFromString
}
from
'
../common/utils
'
;
...
...
@@ -15,7 +14,6 @@ export default class Overlay {
constructor
(
options
,
window
,
document
)
{
this
.
options
=
options
;
this
.
positionToHighlight
=
new
Position
({});
// position at which layover is to be patched at
this
.
highlightedElement
=
null
;
// currently highlighted dom element (instance of Element)
this
.
lastHighlightedElement
=
null
;
// element that was highlighted before current one
this
.
hideTimer
=
null
;
...
...
@@ -79,7 +77,6 @@ export default class Overlay {
this
.
lastHighlightedElement
=
this
.
highlightedElement
;
this
.
highlightedElement
=
element
;
this
.
positionToHighlight
=
position
;
this
.
show
();
...
...
@@ -104,20 +101,6 @@ export default class Overlay {
});
}
hideOverlay
()
{
this
.
node
.
style
.
opacity
=
'
0
'
;
this
.
hideTimer
=
window
.
setTimeout
(()
=>
{
this
.
node
.
style
.
position
=
'
absolute
'
;
this
.
node
.
style
.
left
=
''
;
this
.
node
.
style
.
top
=
''
;
this
.
node
.
style
.
bottom
=
''
;
this
.
node
.
style
.
right
=
''
;
this
.
node
.
parentElement
.
removeChild
(
this
.
node
);
},
ANIMATION_DURATION_MS
);
}
/**
* Returns the currently selected element
* @returns {null|*}
...
...
@@ -138,7 +121,7 @@ export default class Overlay {
* Removes the overlay and cancel any listeners
*/
clear
()
{
this
.
positionToHighlight
=
new
Position
();
// Deselect the highlighted element if any
if
(
this
.
highlightedElement
)
{
this
.
highlightedElement
.
onDeselected
(
true
);
}
...
...
@@ -146,7 +129,28 @@ export default class Overlay {
this
.
highlightedElement
=
null
;
this
.
lastHighlightedElement
=
null
;
this
.
hideOverlay
();
if
(
!
this
.
node
)
{
return
;
}
// Clear any existing timers and remove node
this
.
window
.
clearTimeout
(
this
.
hideTimer
);
if
(
this
.
options
.
animate
)
{
this
.
node
.
style
.
opacity
=
'
0
'
;
this
.
hideTimer
=
window
.
setTimeout
(
this
.
removeNode
,
ANIMATION_DURATION_MS
);
}
else
{
this
.
removeNode
();
}
}
/**
* Removes the overlay node if it exists
*/
removeNode
()
{
if
(
this
.
node
&&
this
.
node
.
parentElement
)
{
this
.
node
.
parentElement
.
removeChild
(
this
.
node
);
}
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录