Skip to content

Commit

Permalink
Fix marquee selection bug in newly created graphs (#1263)
Browse files Browse the repository at this point in the history
* [#187619346] Bug fix: Marquee selection broken in newly created graph

* It turns out the bug was brought about by the css transition causing the pixi points background object to experience a *negative* width and height. It didn't matter that it subsequently was given positive values. So the fix is to prevent it from ever getting negative width or height.

* * Code review change
  • Loading branch information
bfinzer authored May 16, 2024
1 parent 3cd5a62 commit 85566b2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions v3/src/components/data-display/pixi/pixi-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ export class PixiPoints {
}

resize(width: number, height: number) {
this.renderer.resize(width, height)
this.background.width = width
this.background.height = height
this.startRendering()
// We only set the background size if the width and height are valid. If we ever set width/height of background to
// negative values, the background won't be able to detect pointer events.
if (width > 0 && height > 0) {
this.renderer.resize(width, height)
this.background.width = width
this.background.height = height
this.startRendering()
}
}

setVisibility(isVisible: boolean) {
Expand Down Expand Up @@ -505,7 +509,6 @@ export class PixiPoints {
// Note that background event handling attempts to pass the event to the element beneath the cursor,
// as if the canvas background were transparent. This facilitates the passing of events to other map layers.
this.background.eventMode = "static"

// Click event redistribution.
this.background.on("click", (event: PIXI.FederatedPointerEvent) => {
const elementUnderneath = getElementUnderCanvas(event)
Expand Down

0 comments on commit 85566b2

Please sign in to comment.