From 712ec0a48f266c78aa92c8cc1367406ef013b535 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 14 Jan 2025 18:35:54 -0500 Subject: [PATCH] Fix issue with snapping lines and polygons to other shapes (closes #1660) This is a regression of #648 that got introduced sometime around the Pixi v8 upgrade #1495 Basically - when drawing, we don't want the drawing shapes to try to hit themselves. --- modules/pixi/PixiFeatureLine.js | 2 +- modules/pixi/PixiFeaturePoint.js | 3 +-- modules/pixi/PixiFeaturePolygon.js | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/pixi/PixiFeatureLine.js b/modules/pixi/PixiFeatureLine.js index 30dfffbcf..cdc9cd1c5 100644 --- a/modules/pixi/PixiFeatureLine.js +++ b/modules/pixi/PixiFeatureLine.js @@ -199,7 +199,7 @@ export class PixiFeatureLine extends AbstractFeature { } // Buffer around line, used for hit area and halo.. - if (this.visible) { + if (this.visible && !this._classes.has('drawing')) { // Rapid#648 - If drawing, `hitArea = null` // what line width to use?? copied the 'casing' calculation from below, improve this later const minwidth = 3; let width = style.casing.width; diff --git a/modules/pixi/PixiFeaturePoint.js b/modules/pixi/PixiFeaturePoint.js index 114dad5b5..4ba119459 100644 --- a/modules/pixi/PixiFeaturePoint.js +++ b/modules/pixi/PixiFeaturePoint.js @@ -285,8 +285,7 @@ export class PixiFeaturePoint extends AbstractFeature { updateHitArea() { if (!this.visible) return; - // Fix for Rapid#648: If we're drawing, we don't need to hit ourselves. - if (this._classes.has('drawing')) { + if (this._classes.has('drawing')) { // Rapid#648 - If drawing, `hitArea = null` this.container.hitArea = null; return; } diff --git a/modules/pixi/PixiFeaturePolygon.js b/modules/pixi/PixiFeaturePolygon.js index 2cf1024b1..0fb623542 100644 --- a/modules/pixi/PixiFeaturePolygon.js +++ b/modules/pixi/PixiFeaturePolygon.js @@ -293,6 +293,8 @@ export class PixiFeaturePolygon extends AbstractFeature { // STROKES strokes.removeChildren(); if (strokes.visible && rings.length) { + strokes.eventMode = this._classes.has('drawing') ? 'none' : 'static'; // Rapid#648 + const lineWidth = isWireframeMode ? 1 : style.fill.width || 2; const strokeStyle = { alpha: 1, @@ -334,7 +336,6 @@ export class PixiFeaturePolygon extends AbstractFeature { stroke.hitArea = new PIXI.Polygon(buffer.perimeter); stroke.label = `stroke${i}`; - stroke.eventMode = 'static'; stroke.sortableChildren = false; strokes.addChild(stroke); } @@ -343,6 +344,8 @@ export class PixiFeaturePolygon extends AbstractFeature { // FILL if (fill.visible && rings.length) { + fill.eventMode = this._classes.has('drawing') ? 'none' : 'static'; // Rapid#648 + const fillStyle = { color: color, alpha: alpha,