Skip to content

Commit

Permalink
Fix the slider buttons
Browse files Browse the repository at this point in the history
The slider drag was preventing buttons to work correctly.
  • Loading branch information
Liax committed Mar 24, 2023
1 parent bacaf3c commit 1460eb2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/ui/molecules/Slider/Slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProp
*/
__currentIndex = 0;

__isDragging = false;

/**
* Get the current index.
*/
Expand Down Expand Up @@ -310,6 +312,8 @@ export class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProp
onSliderDragStart() {
this.__initialX = this.currentSliderItem ? this.currentSliderItem.x : 0;
this.__distanceX = this.__initialX;

this.__isDragging = true;
}

/**
Expand All @@ -331,6 +335,11 @@ export class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProp
* Listen to the Draggable `drop` event and find the new active slide.
*/
onSliderDragDrop(props: DragServiceProps) {
if (!this.__isDragging) {
return;
}
this.__isDragging = false;

if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
return;
}
Expand Down

0 comments on commit 1460eb2

Please sign in to comment.