Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大大大太阳yt
driver.js
提交
e5643f87
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,发现更多精彩内容 >>
提交
e5643f87
编写于
2月 07, 2019
作者:
K
Kamran Ahmed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve performance and fix positioning issue with popover
上级
2d9f2820
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
18 deletion
+17
-18
demo/scripts/demo.js
demo/scripts/demo.js
+3
-0
src/common/utils.js
src/common/utils.js
+1
-2
src/core/element.js
src/core/element.js
+4
-10
src/core/popover.js
src/core/popover.js
+9
-6
未找到文件。
demo/scripts/demo.js
浏览文件 @
e5643f87
...
...
@@ -6,6 +6,7 @@ document.addEventListener('DOMContentLoaded', function () {
{
element
:
document
.
getElementById
(
'
driver-demo-head
'
),
popover
:
{
className
:
'
scoped-driver-popover
'
,
title
:
'
Before we start
'
,
description
:
'
This is just one use-case, make sure to check out the rest of the docs below.
'
,
nextBtnText
:
'
Okay, Start!
'
,
...
...
@@ -102,6 +103,7 @@ document.addEventListener('DOMContentLoaded', function () {
opacity
:
0.8
,
padding
:
5
,
showButtons
:
true
,
className
:
'
boring-scope
'
,
});
boringTourDriver
.
defineSteps
(
tourSteps
);
...
...
@@ -331,6 +333,7 @@ document.addEventListener('DOMContentLoaded', function () {
{
element
:
'
#first-element-introduction
'
,
popover
:
{
className
:
'
first-step-popover-class
'
,
title
:
'
Title on Popover
'
,
description
:
'
Body of the popover
'
,
position
:
'
top
'
...
...
src/common/utils.js
浏览文件 @
e5643f87
/**
* Turn a string into a node
* @param {String} htmlString to convert
* @return {Node} Converted node element
* @return {
HTMLElement|
Node} Converted node element
*/
// eslint-disable-next-line
export
const
createNodeFromString
=
(
htmlString
)
=>
{
const
div
=
document
.
createElement
(
'
div
'
);
div
.
innerHTML
=
htmlString
.
trim
();
...
...
src/core/element.js
浏览文件 @
e5643f87
...
...
@@ -38,14 +38,13 @@ export default class Element {
this
.
overlay
=
overlay
;
this
.
popover
=
popover
;
this
.
stage
=
stage
;
this
.
animationTimeout
=
null
;
}
/**
* Checks if the current element is visible in viewport
* @returns {boolean}
* @p
rivate
* @p
ublic
*/
isInView
()
{
let
top
=
this
.
node
.
offsetTop
;
...
...
@@ -83,10 +82,11 @@ export default class Element {
/**
* Brings the element to middle of the view port if not in view
* @p
rivate
* @p
ublic
*/
bringInView
()
{
if
(
this
.
isInView
())
{
// If the node is not there or already is in view
if
(
!
this
.
node
||
this
.
isInView
())
{
return
;
}
...
...
@@ -196,12 +196,6 @@ export default class Element {
this
.
addHighlightClasses
();
const
highlightedElement
=
this
;
const
popoverElement
=
this
.
popover
;
if
(
popoverElement
&&
!
popoverElement
.
isInView
())
{
popoverElement
.
bringInView
();
}
if
(
!
highlightedElement
.
isInView
())
{
highlightedElement
.
bringInView
();
}
...
...
src/core/popover.js
浏览文件 @
e5643f87
...
...
@@ -42,9 +42,6 @@ export default class Popover extends Element {
this
.
window
=
window
;
this
.
document
=
document
;
this
.
attachNode
();
this
.
hide
();
}
/**
...
...
@@ -53,11 +50,13 @@ export default class Popover extends Element {
*/
attachNode
()
{
let
popover
=
this
.
document
.
getElementById
(
ID_POPOVER
);
if
(
!
popover
)
{
popover
=
createNodeFromString
(
POPOVER_HTML
(
this
.
options
.
className
));
document
.
body
.
appendChild
(
popover
);
if
(
popover
)
{
popover
.
parentElement
.
removeChild
(
popover
);
}
popover
=
createNodeFromString
(
POPOVER_HTML
(
this
.
options
.
className
));
document
.
body
.
appendChild
(
popover
);
this
.
node
=
popover
;
this
.
tipNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_TIP
}
`
);
this
.
titleNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_TITLE
}
`
);
...
...
@@ -117,6 +116,7 @@ export default class Popover extends Element {
* @public
*/
show
(
position
)
{
this
.
attachNode
();
this
.
setInitialState
();
// Set the title and descriptions
...
...
@@ -172,6 +172,9 @@ export default class Popover extends Element {
this
.
autoPosition
(
position
);
break
;
}
// Bring the popover in view port once it is displayed
this
.
bringInView
();
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录