From b670c64208a10c789bc7ab61eddb1f8528ef8daa Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 18 三月 2024 15:22:41 +0800 Subject: [PATCH] # --- zy-asrs-flow/src/pages/map/utils.js | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js index cde1275..58fb2b2 100644 --- a/zy-asrs-flow/src/pages/map/utils.js +++ b/zy-asrs-flow/src/pages/map/utils.js @@ -56,7 +56,6 @@ sprite.off('pointerdown'); sprite.off('click'); - let viewTarget; sprite.on("click", onClick); function onClick(event) { @@ -405,4 +404,27 @@ }); childList = []; } +} + +export const beCenter = (sprite) => { + if (!sprite || !app || !mapContainer) { + return; + } + + mapContainer.scale.set(1); + mapContainer.position.set(0, 0); + + let bounds = sprite.getBounds(); + let centerPoint = { + x: bounds.x + bounds.width / 2, + y: bounds.y + bounds.height / 2 + }; + + let targetPos = { + x: app.renderer.width / 3 - centerPoint.x * mapContainer.scale.x, + y: app.renderer.height / 3 - centerPoint.y * mapContainer.scale.y + }; + + new TWEEDLE.Tween(mapContainer.position).easing(TWEEDLE.Easing.Quadratic.Out) + .to(targetPos, 500).start(); } \ No newline at end of file -- Gitblit v1.9.1