#
luxiaotao1123
2024-03-06 e29fffcbf6cbc426c459156f072ba2edac1716e5
zy-asrs-flow/src/pages/map/utils.js
@@ -14,7 +14,6 @@
export const MapEvent = Object.freeze({
    SELECTION_BOX: Symbol.for(0),
    PAN: Symbol.for(1),
})
export const getRealPosition = (x, y, mapContainer) => {
@@ -29,9 +28,10 @@
    sprite.anchor.set(0.5);
    sprite.cursor = 'pointer';
    sprite.eventMode = 'static';
    sprite.data = {};
}
export const beMovable = (sprite) => {
export const beMovable = (sprite, setDidClickSprite) => {
    sprite.off('pointerup');
    sprite.off('pointerdown');
    sprite.off('click');
@@ -40,6 +40,7 @@
    let dragTarget;
    function onDragStart(event) {
        setDidClickSprite(true);
        dragTarget = event.currentTarget;
        mapContainer.parent.off('pointermove');
        mapContainer.parent.on('pointermove', onDragMove, dragTarget);
@@ -56,10 +57,29 @@
    function onDragEnd() {
        if (dragTarget) {
            setDidClickSprite(false);
            this.parent.off('pointermove');
            dragTarget.alpha = 1;
            dragTarget = null;
        }
    }
}
export const isSpriteInSelectionBox = (sprite, selectionBox) => {
    const spriteBounds = sprite.getBounds();
    const boxBounds = selectionBox.getBounds();
    return spriteBounds.x + spriteBounds.width > boxBounds.x
        && spriteBounds.x < boxBounds.x + boxBounds.width
        && spriteBounds.y + spriteBounds.height > boxBounds.y
        && spriteBounds.y < boxBounds.y + boxBounds.height;
}
export const markSprite = (sprite) => {
    sprite.alpha = 0.5;
}
export const unMarkSprite = (sprite) => {
    sprite.alpha = 1;
}