Fixed the slider mouse down listener

This commit is contained in:
WolverinDEV 2020-04-11 10:55:23 +02:00
parent 76cd711f67
commit 84face7e3b

View file

@ -73,7 +73,7 @@ export function sliderfy(slider: JQuery, options?: SliderOptions) : Slider {
const parent_offset = slider.offset();
const min = parent_offset.left;
const max = parent_offset.left + slider.width();
const current = 'touches' in event ? event.touches[event.touches.length - 1].clientX : event.pageX;
const current = ('touches' in event && Array.isArray(event.touches) && event.touches.length > 0) ? event.touches[event.touches.length - 1].clientX : (event as MouseEvent).pageX;
const range = options.max_value - options.min_value;
const offset = Math.round(((current - min) * (range / options.step)) / (max - min)) * options.step;