protected onGhostPointerMove()

in src/canvastools/ts/CanvasTools/Region/Component/AnchorsComponent.ts [250:287]


    protected onGhostPointerMove(e: PointerEvent) {
        if (this.isDragged) {
            const ghost = (e.target as HTMLElement).getBoundingClientRect();
            const rdx = e.clientX - ghost.left;
            const rdy = e.clientY - ghost.top;

            const offsetX = e.clientX - (e.target as Element).closest("svg").getBoundingClientRect().left;
            const offsetY = e.clientY - (e.target as Element).closest("svg").getBoundingClientRect().top;

            let dx = offsetX - this.dragOrigin.x;
            let dy = offsetY - this.dragOrigin.y;

            if ((rdx < 0 && dx > 0) || (rdx > 0 && dx < 0)) {
                dx = 0;
            }

            if ((rdy < 0 && dy > 0) || (rdy > 0 && dy < 0)) {
                dy = 0;
            }

            if (this.activeAnchorIndex !== 0) {
                const anchorPoint = this.getActiveAnchorPoint(e);
                let p = new Point2D(anchorPoint.x + dx, anchorPoint.y + dy);

                if (this.paperRect !== null) {
                    p = p.boundToRect(this.paperRect);
                }
                window.requestAnimationFrame(() => {
                    this.ghostAnchor.attr({ cx: p.x, cy: p.y });
                });

                this.updateRegion(p);

            }

            this.dragOrigin = new Point2D(offsetX, offsetY);
        }
    }