Skip to content

Commit

Permalink
Add dragBegin/dragEnd flags to callback event object
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Sep 14, 2023
1 parent ce084a7 commit 1bbf742
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/fontra/client/web-components/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class RangeSlider extends LitElement {
this.value = this.defaultValue;
this.tickmarksPositions = [];
this.step = "any";
this.sawMouseDown = false;
this.onChangeCallback = () => {};
}

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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() {
Expand Down

0 comments on commit 1bbf742

Please sign in to comment.