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

publish npm
  • Loading branch information
yyc-git committed May 24, 2019
1 parent 58f6e1c commit 4f3e45b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wonder.js",
"version": "1.1.0-alpha.6",
"version": "1.1.0-alpha.7",
"authors": "Wonder",
"description": "3d webgl engine",
"homepage": "https://github.com/Wonder-Technology/Wonder.js",
Expand Down
Empty file modified src/api/api/APIAPI.re
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions src/job/utils/InitEventJobUtils.re
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ let _fromPCDomEventArr = state => [|
|> WonderBsMost.Most.tap(event => _execMouseDragStartEventHandle(event))
|> WonderBsMost.Most.flatMap(event =>
_fromPointDomEvent("mousemove", state)
/*!
fix chrome bug for getMovementDeltaWhenPointerLocked:
the first movementDelta->x >100!
*/
|> WonderBsMost.Most.skip(1)
|> WonderBsMost.Most.until(
_fromPointDomEvent("mouseup", state)
|> WonderBsMost.Most.tap(event =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ let getMovementDelta = (mouseDomEvent, {eventRecord} as state) =>
);

let convertMouseDomEventToMouseEvent =
(eventName, mouseDomEvent, state)
: mouseEvent => {
(eventName, mouseDomEvent, state): mouseEvent => {
name: eventName,
location: getLocation(mouseDomEvent, state),
locationInView: getLocationInView(mouseDomEvent, state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(~movementX=1, ~movementY=2, ()),
state,
);
let state = EventTool.restore(state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,13 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(
~movementX=1,
~movementY=2,
(),
),
state,
);
let state = EventTool.restore(state);

Expand Down
35 changes: 14 additions & 21 deletions test/unit/job/no_worker/InitEventJob_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(),
state,
);
EventTool.triggerDomEvent(
"mousemove",
Expand Down Expand Up @@ -744,10 +743,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(~pageX=10, ~pageY=20, ()),
state,
);
EventTool.triggerDomEvent(
"mousemove",
Expand All @@ -772,10 +770,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(~pageX=50, ~pageY=80, ()),
state,
);
let state = EventTool.restore(state);

Expand Down Expand Up @@ -824,10 +821,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(~pageX=50, ~pageY=80, ()),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(~pageX=55, ~pageY=110, ()),
state,
);
EventTool.triggerDomEvent(
"mousemove",
Expand Down Expand Up @@ -863,10 +859,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(~which=eventButton, ()),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(~which=eventButton, ()),
state,
);
let state = EventTool.restore(state);

Expand Down Expand Up @@ -2182,10 +2177,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(),
state,
);
EventTool.triggerDomEvent(
"mousemove",
Expand Down Expand Up @@ -2220,10 +2214,9 @@ let _ =
EventTool.getPointEventBindedDom(state),
MouseEventTool.buildMouseEvent(),
);
EventTool.triggerDomEvent(
"mousemove",
EventTool.getPointEventBindedDom(state),
EventTool.triggerFirstMouseDragOverEvent(
MouseEventTool.buildMouseEvent(),
state,
);
EventTool.triggerDomEvent(
"mouseup",
Expand Down
5 changes: 5 additions & 0 deletions test/unit/job/no_worker/tool/EventTool.re
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,9 @@ let restore = state => {
_clearEventQueueMap(.);

ManageEventMainService.unsubscribeDomEventStream(state);
};

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

0 comments on commit 4f3e45b

Please sign in to comment.