Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
ea111b6e
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea111b6e
编写于
9月 20, 2019
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: support mousewheel event record and replay
上级
5c2d8cff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
4 deletion
+56
-4
src/chart/bar/BarView.js
src/chart/bar/BarView.js
+2
-2
test/runTest/Timeline.js
test/runTest/Timeline.js
+32
-0
test/runTest/recorder/recorder.js
test/runTest/recorder/recorder.js
+22
-2
未找到文件。
src/chart/bar/BarView.js
浏览文件 @
ea111b6e
...
@@ -196,7 +196,7 @@ export default echarts.extendChartView({
...
@@ -196,7 +196,7 @@ export default echarts.extendChartView({
this
.
group
.
setClipPath
(
clipPath
);
this
.
group
.
setClipPath
(
clipPath
);
}
}
else
{
else
{
this
.
group
.
removeClipPath
(
null
);
this
.
group
.
removeClipPath
();
}
}
},
},
...
@@ -258,7 +258,7 @@ var clip = {
...
@@ -258,7 +258,7 @@ var clip = {
layout
.
width
=
x2
-
x
;
layout
.
width
=
x2
-
x
;
layout
.
height
=
y2
-
y
;
layout
.
height
=
y2
-
y
;
var
clipped
=
layout
.
width
<
0
||
layout
.
height
<
0
;
;
var
clipped
=
layout
.
width
<
0
||
layout
.
height
<
0
;
// Reverse back
// Reverse back
if
(
signWidth
<
0
)
{
if
(
signWidth
<
0
)
{
...
...
test/runTest/Timeline.js
浏览文件 @
ea111b6e
...
@@ -29,6 +29,8 @@ module.exports = class Timeline {
...
@@ -29,6 +29,8 @@ module.exports = class Timeline {
this
.
_ops
=
[];
this
.
_ops
=
[];
this
.
_currentOpIndex
=
0
;
this
.
_currentOpIndex
=
0
;
this
.
_client
;
}
}
_reset
()
{
_reset
()
{
...
@@ -39,6 +41,10 @@ module.exports = class Timeline {
...
@@ -39,6 +41,10 @@ module.exports = class Timeline {
async
runAction
(
action
,
takeScreenshot
,
playbackSpeed
)
{
async
runAction
(
action
,
takeScreenshot
,
playbackSpeed
)
{
if
(
!
this
.
_client
)
{
this
.
_client
=
await
this
.
_page
.
target
().
createCDPSession
();
}
this
.
stop
();
this
.
stop
();
playbackSpeed
=
playbackSpeed
||
1
;
playbackSpeed
=
playbackSpeed
||
1
;
...
@@ -108,6 +114,32 @@ module.exports = class Timeline {
...
@@ -108,6 +114,32 @@ module.exports = class Timeline {
case
'
mousemove
'
:
case
'
mousemove
'
:
await
page
.
mouse
.
move
(
op
.
x
,
op
.
y
);
await
page
.
mouse
.
move
(
op
.
x
,
op
.
y
);
break
;
break
;
case
'
mousewheel
'
:
await
page
.
evaluate
((
x
,
y
,
deltaX
,
deltaY
)
=>
{
let
element
=
document
.
elementFromPoint
(
x
,
y
);
// Here dispatch mousewheel event because echarts used it.
// TODO Consider upgrade?
let
event
=
new
WheelEvent
(
'
mousewheel
'
,
{
// PENDING
// Needs inverse delta?
deltaY
,
clientX
:
x
,
clientY
:
y
,
// Needs bubble to parent container
bubbles
:
true
});
element
.
dispatchEvent
(
event
);
},
op
.
x
,
op
.
y
,
op
.
deltaX
||
0
,
op
.
deltaY
);
// console.log('mousewheel', op.x, op.y, op.deltaX, op.deltaY);
// await this._client.send('Input.dispatchMouseEvent', {
// type: 'mouseWheel',
// x: op.x,
// y: op.y,
// deltaX: op.deltaX,
// deltaY: op.deltaY
// });
// break;
case
'
screenshot
'
:
case
'
screenshot
'
:
await
takeScreenshot
();
await
takeScreenshot
();
break
;
break
;
...
...
test/runTest/recorder/recorder.js
浏览文件 @
ea111b6e
...
@@ -143,6 +143,7 @@ const app = new Vue({
...
@@ -143,6 +143,7 @@ const app = new Vue({
if
(
action
)
{
if
(
action
)
{
action
.
ops
=
[];
action
.
ops
=
[];
}
}
saveData
();
}).
catch
(
e
=>
{});
}).
catch
(
e
=>
{});
},
},
...
@@ -240,6 +241,10 @@ function keyboardRecordingHandler(e) {
...
@@ -240,6 +241,10 @@ function keyboardRecordingHandler(e) {
}
}
}
}
function
sign
(
value
)
{
return
value
>
0
?
1
:
-
1
;
}
function
recordIframeEvents
(
iframe
,
app
)
{
function
recordIframeEvents
(
iframe
,
app
)
{
let
innerDocument
=
iframe
.
contentWindow
.
document
;
let
innerDocument
=
iframe
.
contentWindow
.
document
;
...
@@ -247,12 +252,23 @@ function recordIframeEvents(iframe, app) {
...
@@ -247,12 +252,23 @@ function recordIframeEvents(iframe, app) {
function
addMouseOp
(
type
,
e
)
{
function
addMouseOp
(
type
,
e
)
{
if
(
app
.
recordingAction
)
{
if
(
app
.
recordingAction
)
{
let
time
=
getEventTime
();
let
time
=
getEventTime
();
app
.
recordingAction
.
ops
.
push
(
{
let
op
=
{
type
,
type
,
time
:
time
,
time
:
time
,
x
:
e
.
clientX
,
x
:
e
.
clientX
,
y
:
e
.
clientY
y
:
e
.
clientY
});
};
app
.
recordingAction
.
ops
.
push
(
op
);
if
(
type
===
'
mousewheel
'
)
{
// TODO Sreenshot after mousewheel?
op
.
deltaY
=
e
.
deltaY
;
// In a reversed direction.
// When creating WheelEvent, the sign of wheelData and deltaY are same
if
(
sign
(
e
.
wheelDelta
)
!==
sign
(
e
.
deltaY
))
{
op
.
deltaY
=
-
op
.
deltaY
;
}
}
if
(
type
===
'
mouseup
'
&&
app
.
config
.
screenshotAfterMouseUp
)
{
if
(
type
===
'
mouseup
'
&&
app
.
config
.
screenshotAfterMouseUp
)
{
// Add a auto screenshot after mouseup
// Add a auto screenshot after mouseup
app
.
recordingAction
.
ops
.
push
({
app
.
recordingAction
.
ops
.
push
({
...
@@ -288,6 +304,10 @@ function recordIframeEvents(iframe, app) {
...
@@ -288,6 +304,10 @@ function recordIframeEvents(iframe, app) {
}
}
preventRecordingFollowingMouseEvents
=
false
;
preventRecordingFollowingMouseEvents
=
false
;
},
true
);
},
true
);
iframe
.
contentWindow
.
addEventListener
(
'
mousewheel
'
,
e
=>
{
console
.
log
(
e
);
addMouseOp
(
'
mousewheel
'
,
e
);
},
true
);
innerDocument
.
body
.
addEventListener
(
'
change
'
,
e
=>
{
innerDocument
.
body
.
addEventListener
(
'
change
'
,
e
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录