From 35da90afa9ff14329d1aec8511c5bf0f2e809029 Mon Sep 17 00:00:00 2001 From: ienaga Date: Fri, 29 Nov 2024 22:47:52 +0900 Subject: [PATCH] =?UTF-8?q?#154=20PointerMove=E3=82=92=E5=AE=9F=E8=A3=85(W?= =?UTF-8?q?IP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PlayerPointerMoveEventService.ts | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Player/service/PlayerPointerMoveEventService.ts b/packages/core/src/Player/service/PlayerPointerMoveEventService.ts index 7a04fca8..27842ed4 100644 --- a/packages/core/src/Player/service/PlayerPointerMoveEventService.ts +++ b/packages/core/src/Player/service/PlayerPointerMoveEventService.ts @@ -1,10 +1,13 @@ import type { DisplayObject } from "@next2d/display"; +import { $stage } from "@next2d/display"; import { $getSelectedTextField } from "@next2d/text"; import { PointerEvent } from "@next2d/events"; import { $player } from "../../Player"; import { $hitObject, - $hitMatrix + $hitMatrix, + $setRollOverDisplayObject, + $getRollOverDisplayObject } from "../../CoreUtil"; /** @@ -30,14 +33,65 @@ export const execute = (): void => return ; } + const rollOverDisplayObject = $getRollOverDisplayObject(); const displayObject = $hitObject.hit as D; if (displayObject) { + + // pointerMove if (displayObject.willTrigger(PointerEvent.POINTER_MOVE)) { displayObject.dispatchEvent(new PointerEvent( PointerEvent.POINTER_MOVE )); } + + // rollOut and rollOver + if (rollOverDisplayObject) { + + if (rollOverDisplayObject.instanceId !== displayObject.instanceId) { + + // rollOut + if (rollOverDisplayObject.willTrigger(PointerEvent.POINTER_OUT)) { + rollOverDisplayObject.dispatchEvent(new PointerEvent( + PointerEvent.POINTER_OUT + )); + } + + // rollOver + if (displayObject.willTrigger(PointerEvent.POINTER_OVER)) { + displayObject.dispatchEvent(new PointerEvent( + PointerEvent.POINTER_OVER + )); + } + } + + } else { + // rollOver + if (displayObject.willTrigger(PointerEvent.POINTER_OVER)) { + displayObject.dispatchEvent(new PointerEvent( + PointerEvent.POINTER_OVER + )); + } + } + + // set rollOver DisplayObject + $setRollOverDisplayObject(displayObject); + } else { - // console.log(page_x, page_y); + + // rollOut + if (rollOverDisplayObject) { + if (rollOverDisplayObject.willTrigger(PointerEvent.POINTER_OUT)) { + rollOverDisplayObject.dispatchEvent(new PointerEvent( + PointerEvent.POINTER_OUT + )); + } + $setRollOverDisplayObject(null); + } + + if ($stage.hasEventListener(PointerEvent.POINTER_MOVE)) { + $stage.dispatchEvent(new PointerEvent( + PointerEvent.POINTER_MOVE + )); + } } }; \ No newline at end of file