protected onGhostPointerMove()

in src/canvastools/ts/CanvasTools/Region/Polyline/AnchorsElement.ts [183:217]


    protected onGhostPointerMove(e: PointerEvent) {
        if (e.ctrlKey && this.activeAnchorIndex !== 0) {
            const p = this.getActiveAnchorPoint(e);
            let dist: number = Number.MAX_VALUE;
            let index: number = -1;
            this.regionData.points.forEach((point, i) => {
                const d = p.squareDistanceToPoint(point);
                if (d < dist) {
                    dist = d;
                    index = i;
                }
            });

            const swapToDelete: boolean = dist < AnchorsElement.ANCHOR_POINT_LINE_SWITCH_THRESHOLD;

            if (this.addOnPointerUp && this.activeAnchorIndex < 0 && !swapToDelete) {
                this.ghostAnchor.addClass("add");
                this.activeAnchorIndex = -1;

            } else if (this.regionData.points.length > 2 || swapToDelete) {
                this.ghostAnchor.removeClass("add");
                this.ghostAnchor.addClass("delete");
                this.activeAnchorIndex = index + 1;
                this.deleteOnPointerUp = true;
                this.addOnPointerUp = false;
            }
        } else {
            this.ghostAnchor.removeClass("delete");
            this.ghostAnchor.removeClass("add");
            this.deleteOnPointerUp = false;
            this.addOnPointerUp = false;
        }

        super.onGhostPointerMove(e);
    }