From 847599f4bc816d05e1d88bd155384f23c1b3ddde Mon Sep 17 00:00:00 2001 From: Jonah Jeleniewski Date: Sat, 29 Oct 2022 21:06:51 +1100 Subject: [PATCH] Handle pointer capture loss during palette resize --- CHANGELOG.md | 1 + src/core/components/palette.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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")); }