Browse Source

Add `scrolling` event.

Naotoshi Fujita 2 years ago
parent
commit
b473b94a5a

File diff suppressed because it is too large
+ 0 - 0
dist/js/splide-renderer.min.js.map


+ 50 - 20
dist/js/splide.cjs.js

@@ -424,6 +424,7 @@ const EVENT_DRAG = "drag";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGED = "dragged";
 const EVENT_DRAGGED = "dragged";
 const EVENT_SCROLL = "scroll";
 const EVENT_SCROLL = "scroll";
+const EVENT_SCROLLING = "scrolling";
 const EVENT_SCROLLED = "scrolled";
 const EVENT_SCROLLED = "scrolled";
 const EVENT_OVERFLOW = "overflow";
 const EVENT_OVERFLOW = "overflow";
 const EVENT_DESTROY = "destroy";
 const EVENT_DESTROY = "destroy";
@@ -530,8 +531,7 @@ const ORIENTATION_MAP = {
   ArrowRight: [ARROW_DOWN, ARROW_LEFT]
   ArrowRight: [ARROW_DOWN, ARROW_LEFT]
 };
 };
 const Direction = (Splide2, Components2, options) => {
 const Direction = (Splide2, Components2, options) => {
-  function resolve(prop, axisOnly, direction) {
-    direction = direction || options.direction;
+  function resolve(prop, axisOnly, direction = options.direction) {
     const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
     const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
     return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, (match, offset) => {
     return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, (match, offset) => {
       const replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
       const replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
@@ -1176,6 +1176,7 @@ const Move = (Splide, Components, options, event) => {
   const { resolve, orient } = Components.Direction;
   const { resolve, orient } = Components.Direction;
   const { list, track } = Components.Elements;
   const { list, track } = Components.Elements;
   let Transition;
   let Transition;
+  let indices;
   function mount() {
   function mount() {
     Transition = Components.Transition;
     Transition = Components.Transition;
     on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
     on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
@@ -1188,12 +1189,11 @@ const Move = (Splide, Components, options, event) => {
     }
     }
   }
   }
   function move(dest, index, prev, callback) {
   function move(dest, index, prev, callback) {
+    Transition.cancel();
     if (dest !== index && canShift(dest > prev)) {
     if (dest !== index && canShift(dest > prev)) {
-      cancel();
       translate(shift(getPosition(), dest > prev), true);
       translate(shift(getPosition(), dest > prev), true);
-    } else {
-      Transition.cancel();
     }
     }
+    indices = [index, prev, dest];
     set(MOVING);
     set(MOVING);
     emit(EVENT_MOVE, index, prev, dest);
     emit(EVENT_MOVE, index, prev, dest);
     Transition.start(index, () => {
     Transition.start(index, () => {
@@ -1214,10 +1214,9 @@ const Move = (Splide, Components, options, event) => {
   }
   }
   function loop(position) {
   function loop(position) {
     if (Splide.is(LOOP)) {
     if (Splide.is(LOOP)) {
-      const exceededMax = exceededLimit(true, position);
-      const exceededMin = exceededLimit(false, position);
-      if (exceededMin || exceededMax) {
-        position = shift(position, exceededMax);
+      const diff = orient(position) - orient(getPosition());
+      if (diff && exceededLimit(diff > 0, position)) {
+        position = shift(position, diff > 0);
       }
       }
     }
     }
     return position;
     return position;
@@ -1229,8 +1228,11 @@ const Move = (Splide, Components, options, event) => {
     return position;
     return position;
   }
   }
   function cancel() {
   function cancel() {
-    translate(getPosition(), true);
-    Transition.cancel();
+    if (Splide.state.is(MOVING) && indices) {
+      translate(getPosition(), true);
+      Transition.cancel();
+      emit(EVENT_MOVED, ...indices);
+    }
   }
   }
   function toIndex(position) {
   function toIndex(position) {
     const slides = Slides.get();
     const slides = Slides.get();
@@ -1256,6 +1258,25 @@ const Move = (Splide, Components, options, event) => {
     const left = resolve("left");
     const left = resolve("left");
     return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
     return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
   }
   }
+  function getRate() {
+    let rate;
+    if (Splide.is(FADE)) {
+      rate = Splide.index / (Splide.length - 1);
+    } else {
+      const isLoop = Splide.is(LOOP);
+      const position = orient(getPosition());
+      const min = orient(getLimit(false));
+      const max = orient(getLimit(true));
+      const size = sliderSize();
+      const curr = (position - min) % size;
+      const base = isLoop ? size : max - min;
+      rate = curr / base || 0;
+      if (isLoop && rate < 0) {
+        rate += 1;
+      }
+    }
+    return clamp(rate, 0, 1);
+  }
   function trim(position) {
   function trim(position) {
     if (options.trimSpace && Splide.is(SLIDE)) {
     if (options.trimSpace && Splide.is(SLIDE)) {
       position = clamp(position, 0, orient(sliderSize(true) - listSize()));
       position = clamp(position, 0, orient(sliderSize(true) - listSize()));
@@ -1289,6 +1310,7 @@ const Move = (Splide, Components, options, event) => {
     toIndex,
     toIndex,
     toPosition,
     toPosition,
     getPosition,
     getPosition,
+    getRate,
     getLimit,
     getLimit,
     exceededLimit,
     exceededLimit,
     reposition,
     reposition,
@@ -1681,22 +1703,28 @@ const Scroll = (Splide, Components, options, event) => {
     on([EVENT_UPDATED, EVENT_REFRESH], cancel);
     on([EVENT_UPDATED, EVENT_REFRESH], cancel);
   }
   }
   function scroll(destination, duration, snap, onScrolled, noConstrain) {
   function scroll(destination, duration, snap, onScrolled, noConstrain) {
-    const from = getPosition();
     clear();
     clear();
-    if (snap && (!isSlide || !exceededLimit())) {
-      const size = Components.Layout.sliderSize();
-      const offset = sign(destination) * size * floor(abs(destination) / size) || 0;
-      destination = Move.toPosition(Components.Controller.toDest(destination % size)) + offset;
-    }
-    const immediately = approximatelyEqual(from, destination, 1) || duration === 0;
+    const dest = computeDestination(destination, snap);
+    const from = getPosition();
+    const immediately = approximatelyEqual(from, dest, 1) || duration === 0;
     friction = 1;
     friction = 1;
-    duration = immediately ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
+    duration = immediately ? 0 : duration || max(abs(dest - from) / BASE_VELOCITY, MIN_DURATION);
     callback = onScrolled;
     callback = onScrolled;
-    interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
+    interval = RequestInterval(duration, onEnd, apply(update, from, dest, noConstrain), 1);
     set(SCROLLING);
     set(SCROLLING);
     emit(EVENT_SCROLL);
     emit(EVENT_SCROLL);
     interval.start();
     interval.start();
   }
   }
+  function computeDestination(destination, snap) {
+    if (snap) {
+      if (!isSlide || !exceededLimit()) {
+        const position = destination % Components.Layout.sliderSize();
+        const snapped = Move.toPosition(Components.Controller.toDest(position));
+        destination -= position - snapped;
+      }
+    }
+    return destination;
+  }
   function onEnd() {
   function onEnd() {
     set(IDLE);
     set(IDLE);
     callback && callback();
     callback && callback();
@@ -1708,6 +1736,7 @@ const Scroll = (Splide, Components, options, event) => {
     const target = from + (to - from) * easingFunc(rate);
     const target = from + (to - from) * easingFunc(rate);
     const diff = (target - position) * friction;
     const diff = (target - position) * friction;
     translate(position + diff);
     translate(position + diff);
+    emit(EVENT_SCROLLING);
     if (isSlide && !noConstrain && exceededLimit()) {
     if (isSlide && !noConstrain && exceededLimit()) {
       friction *= FRICTION_FACTOR;
       friction *= FRICTION_FACTOR;
       if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
       if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
@@ -2969,6 +2998,7 @@ exports.EVENT_RESIZE = EVENT_RESIZE;
 exports.EVENT_RESIZED = EVENT_RESIZED;
 exports.EVENT_RESIZED = EVENT_RESIZED;
 exports.EVENT_SCROLL = EVENT_SCROLL;
 exports.EVENT_SCROLL = EVENT_SCROLL;
 exports.EVENT_SCROLLED = EVENT_SCROLLED;
 exports.EVENT_SCROLLED = EVENT_SCROLLED;
+exports.EVENT_SCROLLING = EVENT_SCROLLING;
 exports.EVENT_SHIFTED = EVENT_SHIFTED;
 exports.EVENT_SHIFTED = EVENT_SHIFTED;
 exports.EVENT_SLIDE_KEYDOWN = EVENT_SLIDE_KEYDOWN;
 exports.EVENT_SLIDE_KEYDOWN = EVENT_SLIDE_KEYDOWN;
 exports.EVENT_UPDATED = EVENT_UPDATED;
 exports.EVENT_UPDATED = EVENT_UPDATED;

+ 50 - 21
dist/js/splide.esm.js

@@ -420,6 +420,7 @@ const EVENT_DRAG = "drag";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGED = "dragged";
 const EVENT_DRAGGED = "dragged";
 const EVENT_SCROLL = "scroll";
 const EVENT_SCROLL = "scroll";
+const EVENT_SCROLLING = "scrolling";
 const EVENT_SCROLLED = "scrolled";
 const EVENT_SCROLLED = "scrolled";
 const EVENT_OVERFLOW = "overflow";
 const EVENT_OVERFLOW = "overflow";
 const EVENT_DESTROY = "destroy";
 const EVENT_DESTROY = "destroy";
@@ -526,8 +527,7 @@ const ORIENTATION_MAP = {
   ArrowRight: [ARROW_DOWN, ARROW_LEFT]
   ArrowRight: [ARROW_DOWN, ARROW_LEFT]
 };
 };
 const Direction = (Splide2, Components2, options) => {
 const Direction = (Splide2, Components2, options) => {
-  function resolve(prop, axisOnly, direction) {
-    direction = direction || options.direction;
+  function resolve(prop, axisOnly, direction = options.direction) {
     const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
     const index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
     return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, (match, offset) => {
     return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, (match, offset) => {
       const replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
       const replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match;
@@ -1172,6 +1172,7 @@ const Move = (Splide, Components, options, event) => {
   const { resolve, orient } = Components.Direction;
   const { resolve, orient } = Components.Direction;
   const { list, track } = Components.Elements;
   const { list, track } = Components.Elements;
   let Transition;
   let Transition;
+  let indices;
   function mount() {
   function mount() {
     Transition = Components.Transition;
     Transition = Components.Transition;
     on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
     on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
@@ -1184,12 +1185,11 @@ const Move = (Splide, Components, options, event) => {
     }
     }
   }
   }
   function move(dest, index, prev, callback) {
   function move(dest, index, prev, callback) {
+    Transition.cancel();
     if (dest !== index && canShift(dest > prev)) {
     if (dest !== index && canShift(dest > prev)) {
-      cancel();
       translate(shift(getPosition(), dest > prev), true);
       translate(shift(getPosition(), dest > prev), true);
-    } else {
-      Transition.cancel();
     }
     }
+    indices = [index, prev, dest];
     set(MOVING);
     set(MOVING);
     emit(EVENT_MOVE, index, prev, dest);
     emit(EVENT_MOVE, index, prev, dest);
     Transition.start(index, () => {
     Transition.start(index, () => {
@@ -1210,10 +1210,9 @@ const Move = (Splide, Components, options, event) => {
   }
   }
   function loop(position) {
   function loop(position) {
     if (Splide.is(LOOP)) {
     if (Splide.is(LOOP)) {
-      const exceededMax = exceededLimit(true, position);
-      const exceededMin = exceededLimit(false, position);
-      if (exceededMin || exceededMax) {
-        position = shift(position, exceededMax);
+      const diff = orient(position) - orient(getPosition());
+      if (diff && exceededLimit(diff > 0, position)) {
+        position = shift(position, diff > 0);
       }
       }
     }
     }
     return position;
     return position;
@@ -1225,8 +1224,11 @@ const Move = (Splide, Components, options, event) => {
     return position;
     return position;
   }
   }
   function cancel() {
   function cancel() {
-    translate(getPosition(), true);
-    Transition.cancel();
+    if (Splide.state.is(MOVING) && indices) {
+      translate(getPosition(), true);
+      Transition.cancel();
+      emit(EVENT_MOVED, ...indices);
+    }
   }
   }
   function toIndex(position) {
   function toIndex(position) {
     const slides = Slides.get();
     const slides = Slides.get();
@@ -1252,6 +1254,25 @@ const Move = (Splide, Components, options, event) => {
     const left = resolve("left");
     const left = resolve("left");
     return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
     return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
   }
   }
+  function getRate() {
+    let rate;
+    if (Splide.is(FADE)) {
+      rate = Splide.index / (Splide.length - 1);
+    } else {
+      const isLoop = Splide.is(LOOP);
+      const position = orient(getPosition());
+      const min = orient(getLimit(false));
+      const max = orient(getLimit(true));
+      const size = sliderSize();
+      const curr = (position - min) % size;
+      const base = isLoop ? size : max - min;
+      rate = curr / base || 0;
+      if (isLoop && rate < 0) {
+        rate += 1;
+      }
+    }
+    return clamp(rate, 0, 1);
+  }
   function trim(position) {
   function trim(position) {
     if (options.trimSpace && Splide.is(SLIDE)) {
     if (options.trimSpace && Splide.is(SLIDE)) {
       position = clamp(position, 0, orient(sliderSize(true) - listSize()));
       position = clamp(position, 0, orient(sliderSize(true) - listSize()));
@@ -1285,6 +1306,7 @@ const Move = (Splide, Components, options, event) => {
     toIndex,
     toIndex,
     toPosition,
     toPosition,
     getPosition,
     getPosition,
+    getRate,
     getLimit,
     getLimit,
     exceededLimit,
     exceededLimit,
     reposition,
     reposition,
@@ -1677,22 +1699,28 @@ const Scroll = (Splide, Components, options, event) => {
     on([EVENT_UPDATED, EVENT_REFRESH], cancel);
     on([EVENT_UPDATED, EVENT_REFRESH], cancel);
   }
   }
   function scroll(destination, duration, snap, onScrolled, noConstrain) {
   function scroll(destination, duration, snap, onScrolled, noConstrain) {
-    const from = getPosition();
     clear();
     clear();
-    if (snap && (!isSlide || !exceededLimit())) {
-      const size = Components.Layout.sliderSize();
-      const offset = sign(destination) * size * floor(abs(destination) / size) || 0;
-      destination = Move.toPosition(Components.Controller.toDest(destination % size)) + offset;
-    }
-    const immediately = approximatelyEqual(from, destination, 1) || duration === 0;
+    const dest = computeDestination(destination, snap);
+    const from = getPosition();
+    const immediately = approximatelyEqual(from, dest, 1) || duration === 0;
     friction = 1;
     friction = 1;
-    duration = immediately ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
+    duration = immediately ? 0 : duration || max(abs(dest - from) / BASE_VELOCITY, MIN_DURATION);
     callback = onScrolled;
     callback = onScrolled;
-    interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
+    interval = RequestInterval(duration, onEnd, apply(update, from, dest, noConstrain), 1);
     set(SCROLLING);
     set(SCROLLING);
     emit(EVENT_SCROLL);
     emit(EVENT_SCROLL);
     interval.start();
     interval.start();
   }
   }
+  function computeDestination(destination, snap) {
+    if (snap) {
+      if (!isSlide || !exceededLimit()) {
+        const position = destination % Components.Layout.sliderSize();
+        const snapped = Move.toPosition(Components.Controller.toDest(position));
+        destination -= position - snapped;
+      }
+    }
+    return destination;
+  }
   function onEnd() {
   function onEnd() {
     set(IDLE);
     set(IDLE);
     callback && callback();
     callback && callback();
@@ -1704,6 +1732,7 @@ const Scroll = (Splide, Components, options, event) => {
     const target = from + (to - from) * easingFunc(rate);
     const target = from + (to - from) * easingFunc(rate);
     const diff = (target - position) * friction;
     const diff = (target - position) * friction;
     translate(position + diff);
     translate(position + diff);
+    emit(EVENT_SCROLLING);
     if (isSlide && !noConstrain && exceededLimit()) {
     if (isSlide && !noConstrain && exceededLimit()) {
       friction *= FRICTION_FACTOR;
       friction *= FRICTION_FACTOR;
       if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
       if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
@@ -2907,4 +2936,4 @@ class SplideRenderer {
   }
   }
 }
 }
 
 
-export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, DEFAULTS, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_ERROR, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, FADE, LOOP, LTR, RTL, SLIDE, STATUS_CLASSES, Splide, SplideRenderer, TTB, Splide as default };
+export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, DEFAULTS, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_ERROR, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SCROLLING, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, FADE, LOOP, LTR, RTL, SLIDE, STATUS_CLASSES, Splide, SplideRenderer, TTB, Splide as default };

+ 2 - 0
dist/js/splide.js

@@ -423,6 +423,7 @@
   const EVENT_DRAGGING = "dragging";
   const EVENT_DRAGGING = "dragging";
   const EVENT_DRAGGED = "dragged";
   const EVENT_DRAGGED = "dragged";
   const EVENT_SCROLL = "scroll";
   const EVENT_SCROLL = "scroll";
+  const EVENT_SCROLLING = "scrolling";
   const EVENT_SCROLLED = "scrolled";
   const EVENT_SCROLLED = "scrolled";
   const EVENT_OVERFLOW = "overflow";
   const EVENT_OVERFLOW = "overflow";
   const EVENT_DESTROY = "destroy";
   const EVENT_DESTROY = "destroy";
@@ -1731,6 +1732,7 @@
       const target = from + (to - from) * easingFunc(rate);
       const target = from + (to - from) * easingFunc(rate);
       const diff = (target - position) * friction;
       const diff = (target - position) * friction;
       translate(position + diff);
       translate(position + diff);
+      emit(EVENT_SCROLLING);
       if (isSlide && !noConstrain && exceededLimit()) {
       if (isSlide && !noConstrain && exceededLimit()) {
         friction *= FRICTION_FACTOR;
         friction *= FRICTION_FACTOR;
         if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
         if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {

File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.min.js


BIN
dist/js/splide.min.js.gz


File diff suppressed because it is too large
+ 0 - 0
dist/js/splide.min.js.map


+ 4 - 1
dist/types/index.d.ts

@@ -217,6 +217,7 @@ interface MoveComponent extends BaseComponent {
     toIndex(position: number): number;
     toIndex(position: number): number;
     toPosition(index: number, trimming?: boolean): number;
     toPosition(index: number, trimming?: boolean): number;
     getPosition(): number;
     getPosition(): number;
+    getRate(): number;
     getLimit(max: boolean): number;
     getLimit(max: boolean): number;
     exceededLimit(max?: boolean | undefined, position?: number): boolean;
     exceededLimit(max?: boolean | undefined, position?: number): boolean;
     /** @internal */
     /** @internal */
@@ -779,6 +780,7 @@ declare const EVENT_DRAG = "drag";
 declare const EVENT_DRAGGING = "dragging";
 declare const EVENT_DRAGGING = "dragging";
 declare const EVENT_DRAGGED = "dragged";
 declare const EVENT_DRAGGED = "dragged";
 declare const EVENT_SCROLL = "scroll";
 declare const EVENT_SCROLL = "scroll";
+declare const EVENT_SCROLLING = "scrolling";
 declare const EVENT_SCROLLED = "scrolled";
 declare const EVENT_SCROLLED = "scrolled";
 declare const EVENT_OVERFLOW = "overflow";
 declare const EVENT_OVERFLOW = "overflow";
 declare const EVENT_DESTROY = "destroy";
 declare const EVENT_DESTROY = "destroy";
@@ -820,6 +822,7 @@ interface EventMap {
     [EVENT_DRAGGING]: () => void;
     [EVENT_DRAGGING]: () => void;
     [EVENT_DRAGGED]: () => void;
     [EVENT_DRAGGED]: () => void;
     [EVENT_SCROLL]: () => void;
     [EVENT_SCROLL]: () => void;
+    [EVENT_SCROLLING]: () => void;
     [EVENT_SCROLLED]: () => void;
     [EVENT_SCROLLED]: () => void;
     [EVENT_OVERFLOW]: (overflow: boolean) => void;
     [EVENT_OVERFLOW]: (overflow: boolean) => void;
     [EVENT_DESTROY]: () => void;
     [EVENT_DESTROY]: () => void;
@@ -1719,4 +1722,4 @@ declare const LOOP = "loop";
  */
  */
 declare const FADE = "fade";
 declare const FADE = "fade";
 
 
-export { AnyFunction, ArrowsComponent, AutoplayComponent, BaseComponent, BreakpointsComponent, CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, Cast, ClonesComponent, ComponentConstructor, Components, ControllerComponent, DEFAULTS, DirectionComponent, DragComponent, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_ERROR, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, ElementsComponent, EventInterface, EventMap, FADE, Head, KeyboardComponent, LOOP, LTR, LayoutComponent, LazyLoadComponent, LiveComponent, MoveComponent, Options, PaginationComponent, PaginationData, PaginationItem, Push, RTL, Resolve, ResponsiveOptions, SLIDE, STATUS_CLASSES, ScrollComponent, Shift, ShiftN, SlideComponent, SlidesComponent, Splide, SplideRenderer, SyncComponent, SyncTarget, TTB, TransitionComponent, WheelComponent, Splide as default };
+export { AnyFunction, ArrowsComponent, AutoplayComponent, BaseComponent, BreakpointsComponent, CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_CLONE, CLASS_CONTAINER, CLASS_FOCUS_IN, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_OVERFLOW, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SPINNER, CLASS_SR, CLASS_TOGGLE, CLASS_TOGGLE_PAUSE, CLASS_TOGGLE_PLAY, CLASS_TRACK, CLASS_VISIBLE, Cast, ClonesComponent, ComponentConstructor, Components, ControllerComponent, DEFAULTS, DirectionComponent, DragComponent, EVENT_ACTIVE, EVENT_ARROWS_MOUNTED, EVENT_ARROWS_UPDATED, EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_AUTOPLAY_PLAYING, EVENT_CLICK, EVENT_DESTROY, EVENT_DRAG, EVENT_DRAGGED, EVENT_DRAGGING, EVENT_END_INDEX_CHANGED, EVENT_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_ERROR, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_OVERFLOW, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SCROLLING, EVENT_SHIFTED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, ElementsComponent, EventInterface, EventMap, FADE, Head, KeyboardComponent, LOOP, LTR, LayoutComponent, LazyLoadComponent, LiveComponent, MoveComponent, Options, PaginationComponent, PaginationData, PaginationItem, Push, RTL, Resolve, ResponsiveOptions, SLIDE, STATUS_CLASSES, ScrollComponent, Shift, ShiftN, SlideComponent, SlidesComponent, Splide, SplideRenderer, SyncComponent, SyncTarget, TTB, TransitionComponent, WheelComponent, Splide as default };

+ 9 - 1
src/js/components/Scroll/Scroll.ts

@@ -1,4 +1,11 @@
-import { EVENT_MOVE, EVENT_REFRESH, EVENT_SCROLL, EVENT_SCROLLED, EVENT_UPDATED } from '../../constants/events';
+import {
+  EVENT_MOVE,
+  EVENT_REFRESH,
+  EVENT_SCROLL,
+  EVENT_SCROLLED,
+  EVENT_SCROLLING,
+  EVENT_UPDATED,
+} from '../../constants/events';
 import { IDLE, SCROLLING } from '../../constants/states';
 import { IDLE, SCROLLING } from '../../constants/states';
 import { SLIDE } from '../../constants/types';
 import { SLIDE } from '../../constants/types';
 import { AnyFunction, BaseComponent, ComponentConstructor } from '../../types';
 import { AnyFunction, BaseComponent, ComponentConstructor } from '../../types';
@@ -134,6 +141,7 @@ export const Scroll: ComponentConstructor<ScrollComponent> = ( Splide, Component
     const diff     = ( target - position ) * friction;
     const diff     = ( target - position ) * friction;
 
 
     translate( position + diff );
     translate( position + diff );
+    emit( EVENT_SCROLLING );
 
 
     if ( isSlide && ! noConstrain && exceededLimit() ) {
     if ( isSlide && ! noConstrain && exceededLimit() ) {
       friction *= FRICTION_FACTOR;
       friction *= FRICTION_FACTOR;

+ 1 - 0
src/js/constants/events.ts

@@ -15,6 +15,7 @@ export const EVENT_DRAG               = 'drag';
 export const EVENT_DRAGGING           = 'dragging';
 export const EVENT_DRAGGING           = 'dragging';
 export const EVENT_DRAGGED            = 'dragged';
 export const EVENT_DRAGGED            = 'dragged';
 export const EVENT_SCROLL             = 'scroll';
 export const EVENT_SCROLL             = 'scroll';
+export const EVENT_SCROLLING          = 'scrolling';
 export const EVENT_SCROLLED           = 'scrolled';
 export const EVENT_SCROLLED           = 'scrolled';
 export const EVENT_OVERFLOW           = 'overflow';
 export const EVENT_OVERFLOW           = 'overflow';
 export const EVENT_DESTROY            = 'destroy';
 export const EVENT_DESTROY            = 'destroy';

+ 1 - 0
src/js/types/events.ts

@@ -30,6 +30,7 @@ export interface EventMap {
   [ E.EVENT_DRAGGING ]: () => void;
   [ E.EVENT_DRAGGING ]: () => void;
   [ E.EVENT_DRAGGED ]: () => void;
   [ E.EVENT_DRAGGED ]: () => void;
   [ E.EVENT_SCROLL ]: () => void;
   [ E.EVENT_SCROLL ]: () => void;
+  [ E.EVENT_SCROLLING ]: () => void;
   [ E.EVENT_SCROLLED ]: () => void;
   [ E.EVENT_SCROLLED ]: () => void;
   [ E.EVENT_OVERFLOW ]: ( overflow: boolean ) => void;
   [ E.EVENT_OVERFLOW ]: ( overflow: boolean ) => void;
   [ E.EVENT_DESTROY ]: () => void;
   [ E.EVENT_DESTROY ]: () => void;

Some files were not shown because too many files changed in this diff