Skip to content

Commit

Permalink
Fix issue with snapping lines and polygons to other shapes
Browse files Browse the repository at this point in the history
(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.
  • Loading branch information
bhousel committed Jan 14, 2025
1 parent 3b1c85d commit 712ec0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/pixi/PixiFeatureLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions modules/pixi/PixiFeaturePoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion modules/pixi/PixiFeaturePolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand All @@ -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,
Expand Down

0 comments on commit 712ec0a

Please sign in to comment.