From d60b64fae04eb80b0a66714d960fd0b13d5e27c4 Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Fri, 24 May 2019 18:28:20 +0800 Subject: [PATCH] fix(event): fix init event job->chrome bug for getMovementDeltaWhenPointerLocked update wonder.js version --- package.json | 2 +- src/core/job/init/InitEventJob.re | 5 +++++ test/integration/job/initEventJob_test.re | 16 +++++++--------- test/integration/job/tool/EventTool.re | 7 ++++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 037d576d9..75ef56b75 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/job/init/InitEventJob.re b/src/core/job/init/InitEventJob.re index 8ad2bb680..735e349aa 100755 --- a/src/core/job/init/InitEventJob.re +++ b/src/core/job/init/InitEventJob.re @@ -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 => diff --git a/test/integration/job/initEventJob_test.re b/test/integration/job/initEventJob_test.re index 7fe15d80a..f845c59dc 100755 --- a/test/integration/job/initEventJob_test.re +++ b/test/integration/job/initEventJob_test.re @@ -559,9 +559,7 @@ let _ = (), ), ); - EventTool.triggerDomEvent( - "mousemove", - EventTool.getBody(), + EventTool.triggerFirstMouseDragOverEvent( MouseEventTool.buildMouseDomEvent( ~pageX=movePageX, ~pageY=movePageY, @@ -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", () => diff --git a/test/integration/job/tool/EventTool.re b/test/integration/job/tool/EventTool.re index ad132f845..2012502fa 100755 --- a/test/integration/job/tool/EventTool.re +++ b/test/integration/job/tool/EventTool.re @@ -274,4 +274,9 @@ let getCanvas = () => let buildCanvasTarget = () => {"tagName": "CANVAS"}; -let buildBodyTarget = () => {"tagName": "BODY"}; \ No newline at end of file +let buildBodyTarget = () => {"tagName": "BODY"}; + +let triggerFirstMouseDragOverEvent = mouseEvent => { + triggerDomEvent("mousemove", getBody(), mouseEvent); + triggerDomEvent("mousemove", getBody(), mouseEvent); +}; \ No newline at end of file