Skip to content

Commit

Permalink
fix(event): fix init event job->chrome bug for getMovementDeltaWhenPo…
Browse files Browse the repository at this point in the history
…interLocked

update wonder.js version
  • Loading branch information
yyc-git committed May 24, 2019
1 parent 98e2bb6 commit d60b64f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"wonder-commonlib": "^0.2.32",
"wonder-hotkey": "^0.0.1",
"wonder-log": "^0.2.11",
"wonder.js": "1.1.0-alpha.6"
"wonder.js": "1.1.0-alpha.7"
},
"resolutions": {
"wonder-log": "^0.2.11",
Expand Down
5 changes: 5 additions & 0 deletions src/core/job/init/InitEventJob.re
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ module DomEvent = {
)
|> WonderBsMost.Most.flatMap(event =>
_fromPointDomEvent("mousemove", engineState)
/*!
fix chrome bug for getMovementDeltaWhenPointerLocked:
the first movementDelta->x >100!
*/
|> WonderBsMost.Most.skip(1)
|> WonderBsMost.Most.until(
_fromPointDomEvent("mouseup", engineState)
|> WonderBsMost.Most.tap(event =>
Expand Down
16 changes: 7 additions & 9 deletions test/integration/job/initEventJob_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,7 @@ let _ =
(),
),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getBody(),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseDomEvent(
~pageX=movePageX,
~pageY=movePageY,
Expand All @@ -580,12 +578,12 @@ let _ =
EventTool.restore();

((x1^, y1^), (x2^, y2^), (x3^, y3^))
|>
expect == (
(dragStartLocationInViewX, dragStartLocationInViewY),
(dragOverLocationInViewX, dragOverLocationInViewY),
(dragDropLocationInViewX, dragDropLocationInViewY),
);
|> expect
== (
(dragStartLocationInViewX, dragStartLocationInViewY),
(dragOverLocationInViewX, dragOverLocationInViewY),
(dragDropLocationInViewX, dragDropLocationInViewY),
);
};

describe("test event target is game view", () =>
Expand Down
7 changes: 6 additions & 1 deletion test/integration/job/tool/EventTool.re
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,9 @@ let getCanvas = () =>

let buildCanvasTarget = () => {"tagName": "CANVAS"};

let buildBodyTarget = () => {"tagName": "BODY"};
let buildBodyTarget = () => {"tagName": "BODY"};

let triggerFirstMouseDragOverEvent = mouseEvent => {
triggerDomEvent("mousemove", getBody(), mouseEvent);
triggerDomEvent("mousemove", getBody(), mouseEvent);
};

0 comments on commit d60b64f

Please sign in to comment.