diff --git a/CHANGELOG.md b/CHANGELOG.md index 01df938..090b299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/core/components/palette.js b/src/core/components/palette.js index 4302883..3c98e1b 100644 --- a/src/core/components/palette.js +++ b/src/core/components/palette.js @@ -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")); }