Skip to content

Commit

Permalink
Handle pointer capture loss during palette resize
Browse files Browse the repository at this point in the history
  • Loading branch information
Cirras committed Oct 29, 2022
1 parent b503249 commit 847599f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Draw operations can no longer begin outside of the editor viewport.
- Graceful handling for cases where pointer capture is lost while using a tool.
- Graceful handling for cases where pointer capture is lost while resizing the palette.

### Fixed

Expand Down
13 changes: 9 additions & 4 deletions src/core/components/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,20 @@ export class Palette extends PhaserInstance {

let onPointerUp = (_event) => {
gutter.releasePointerCapture(event.pointerId);
};

let onLostPointerCapture = (_event) => {
this.gutterActive = false;
this.width = this.calcWidth();
this.dispatchEvent(new CustomEvent("resize-end"));
window.removeEventListener("pointermove", onPointerMove);
window.removeEventListener("pointerup", onPointerUp);
gutter.removeEventListener("pointermove", onPointerMove);
gutter.removeEventListener("pointerup", onPointerUp);
gutter.removeEventListener("lostpointercapture", onLostPointerCapture);
};

window.addEventListener("pointermove", onPointerMove);
window.addEventListener("pointerup", onPointerUp);
gutter.addEventListener("pointermove", onPointerMove);
gutter.addEventListener("pointerup", onPointerUp);
gutter.addEventListener("lostpointercapture", onLostPointerCapture);

this.dispatchEvent(new CustomEvent("resize-start"));
}
Expand Down

0 comments on commit 847599f

Please sign in to comment.