Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大大大太阳yt
driver.js
提交
70e2ea81
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,发现更多精彩内容 >>
提交
70e2ea81
编写于
3月 13, 2018
作者:
K
Kamran Ahmed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle animation for the popover
上级
c647bb68
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
18 deletion
+22
-18
src/common/constants.js
src/common/constants.js
+3
-1
src/core/element.js
src/core/element.js
+12
-7
src/core/overlay.js
src/core/overlay.js
+3
-10
src/driver.scss
src/driver.scss
+4
-0
未找到文件。
src/common/constants.js
浏览文件 @
70e2ea81
export
const
OVERLAY_OPACITY
=
0.75
;
export
const
OVERLAY_PADDING
=
10
;
export
const
OVERLAY_ANIMATE
=
true
;
export
const
OVERLAY_ZINDEX
=
'
999999999
'
;
export
const
ESC_KEY_CODE
=
27
;
export
const
LEFT_KEY_CODE
=
37
;
...
...
@@ -20,6 +19,9 @@ export const CLASS_NEXT_STEP_BTN = 'driver-next-btn';
export
const
CLASS_PREV_STEP_BTN
=
'
driver-prev-btn
'
;
export
const
CLASS_BTN_DISABLED
=
'
driver-disabled
'
;
// It must match the one set in the animations in CSS file
export
const
ANIMATION_DURATION_MS
=
200
;
// language=HTML
export
const
POPOVER_HTML
=
`
<div id="
${
ID_POPOVER
}
">
...
...
src/core/element.js
浏览文件 @
70e2ea81
import
Position
from
'
./position
'
;
import
{
ANIMATION_DURATION_MS
}
from
"
../common/constants
"
;
/**
* Wrapper around DOMElements to enrich them
...
...
@@ -154,8 +155,6 @@ export default class Element {
* this element of has just decided to highlight it
*/
onHighlightStarted
()
{
this
.
showPopover
();
// Because element has just started highlighting
// and hasn't completely highlighted
this
.
highlightFinished
=
false
;
...
...
@@ -176,15 +175,16 @@ export default class Element {
this
.
highlightFinished
=
true
;
const
highlightedElement
=
this
;
const
lastHighlightedElement
=
this
.
overlay
.
getLastHighlightedElement
();
const
popoverElement
=
this
.
popover
;
const
highlightedNode
=
this
.
node
;
const
lastHighlightedElement
=
this
.
overlay
.
getLastHighlightedElement
();
const
lastHighlightedNode
=
lastHighlightedElement
&&
lastHighlightedElement
.
node
;
// If this element is not already highlighted (because this call could
// be from the resize or scroll) and is not in view
if
(
highlightedNode
!==
lastHighlightedNode
)
{
const
popoverElement
=
this
.
popover
;
if
(
popoverElement
&&
!
popoverElement
.
isInView
())
{
popoverElement
.
bringInView
();
}
...
...
@@ -223,9 +223,14 @@ export default class Element {
return
;
}
const
position
=
this
.
getCalculatedPosition
();
const
showAtPosition
=
this
.
getCalculatedPosition
();
// For first highlight, show it immediately because there won't be any animation
const
animationDuration
=
!
this
.
overlay
.
lastHighlightedElement
?
0
:
ANIMATION_DURATION_MS
*
2
;
this
.
popover
.
show
(
position
);
window
.
setTimeout
(()
=>
{
this
.
popover
.
show
(
showAtPosition
);
},
animationDuration
);
}
/**
...
...
src/core/overlay.js
浏览文件 @
70e2ea81
import
Position
from
'
./position
'
;
import
{
ID_OVERLAY
,
OVERLAY_HTML
,
POPOVER_HTML
}
from
"
../common/constants
"
;
import
{
createNodeFromString
}
from
"
../common/utils
"
;
import
{
ID_OVERLAY
,
OVERLAY_HTML
}
from
'
../common/constants
'
;
import
{
createNodeFromString
}
from
'
../common/utils
'
;
/**
* Responsible for overlay creation and manipulation i.e.
...
...
@@ -17,7 +17,6 @@ export default class Overlay {
this
.
options
=
options
;
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
.
highlightedElement
=
null
;
// currently highlighted dom element (instance of Element)
this
.
lastHighlightedElement
=
null
;
// element that was highlighted before current one
...
...
@@ -48,7 +47,7 @@ export default class Overlay {
* @param {Element} element
* @param {boolean} animate
*/
highlight
(
element
,
animate
=
true
)
{
highlight
(
element
)
{
if
(
!
element
||
!
element
.
node
)
{
console
.
warn
(
'
Invalid element to highlight. Must be an instance of `Element`
'
);
return
;
...
...
@@ -72,12 +71,6 @@ export default class Overlay {
this
.
highlightedElement
=
element
;
this
.
positionToHighlight
=
position
;
// If animation is not required then set the last path to be same
// as the current path so that there is no easing towards it
if
(
!
this
.
options
.
animate
||
!
animate
)
{
this
.
highlightedPosition
=
this
.
positionToHighlight
;
}
this
.
draw
();
}
...
...
src/driver.scss
浏览文件 @
70e2ea81
...
...
@@ -118,6 +118,8 @@ div#driver-page-overlay {
opacity
:
0
;
pointer-events
:
none
;
z-index
:
100002
!
important
;
// If you update this duration, make sure to update `ANIMATION_DURATION_MS` constant
-webkit-transition
:
all
0
.2s
;
-moz-transition
:
all
0
.2s
;
-ms-transition
:
all
0
.2s
;
...
...
@@ -134,6 +136,8 @@ div#driver-highlighted-element-stage {
background
:
white
;
z-index
:
100003
!
important
;
display
:
none
;
// If you update this duration, make sure to update `ANIMATION_DURATION_MS` constant
-webkit-transition
:
all
0
.2s
;
-moz-transition
:
all
0
.2s
;
-ms-transition
:
all
0
.2s
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录