From 1bbf742a12925fbe899fcb1c38a83cc319f4275c Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Thu, 14 Sep 2023 13:41:04 +0200 Subject: [PATCH] Add dragBegin/dragEnd flags to callback event object --- src/fontra/client/web-components/range-slider.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fontra/client/web-components/range-slider.js b/src/fontra/client/web-components/range-slider.js index 86ee1d439..4caa7ebe1 100644 --- a/src/fontra/client/web-components/range-slider.js +++ b/src/fontra/client/web-components/range-slider.js @@ -164,6 +164,7 @@ export class RangeSlider extends LitElement { this.value = this.defaultValue; this.tickmarksPositions = []; this.step = "any"; + this.sawMouseDown = false; this.onChangeCallback = () => {}; } @@ -238,6 +239,7 @@ export class RangeSlider extends LitElement { } handleMouseDown(event) { + this.sawMouseDown = true; const activeElement = document.activeElement; this._savedCanvasElement = activeElement?.id === "edit-canvas" ? activeElement : undefined; @@ -249,6 +251,8 @@ export class RangeSlider extends LitElement { handleMouseUp(event) { this._savedCanvasElement?.focus(); + this.sawMouseDown = false; + this.onChangeCallback({ value: this.value, dragEnd: true }); } changeValue(event) { @@ -269,7 +273,13 @@ export class RangeSlider extends LitElement { } } this.updateIsAtDefault(); - this.onChangeCallback({ value: this.value }); + + const callbackEvent = { value: this.value }; + if (this.sawMouseDown) { + callbackEvent.dragBegin = true; + } + this.sawMouseDown = false; + this.onChangeCallback(callbackEvent); } updateIsAtDefault() {