Bladeren bron

Replace constructors with the util package.

Naotoshi Fujita 2 jaren geleden
bovenliggende
commit
3bbe359ef5

+ 65 - 90
dist/js/splide.cjs.js

@@ -37,6 +37,9 @@ function m(n, t, e) {
 function a(n) {
   return n.bind(null, ...m(arguments, 1));
 }
+function P(n) {
+  return requestAnimationFrame(n);
+}
 function p(n, t) {
   return typeof t === n;
 }
@@ -53,6 +56,9 @@ function L(n) {
 function d(n, t) {
   L(n).forEach(t);
 }
+function G(n, t) {
+  return n.includes(t);
+}
 const b = Object.assign, A = Object.keys;
 function O(n, t, e) {
   return n && (e ? A(n).reverse() : A(n)).forEach((i) => {
@@ -71,7 +77,7 @@ function _() {
 function on(n, t) {
   return t = $(t) || !g(t) ? { class: _(t) } : t, `<${`${n} ${t ? rn(t) : ""}`.trim()}>`;
 }
-a(on, "div");
+a(on, "div"); const { min: E, max: w, floor: xn, ceil: Dn, abs: un, sign: Fn } = Math;
 function C(n, t) {
   d(n, (e) => {
     h(e) && e.split(" ").forEach(t);
@@ -140,6 +146,59 @@ function fn(n = H(), t = v()) {
   }
   return b({}, n, t, { create: e, destroy: i });
 }
+function sn(n, t, e, i) {
+  const { now: r } = Date;
+  let o, f = 0, u, c = true, s = 0;
+  function l() {
+    if (!c) {
+      if (f = n ? E((r() - o) / n, 1) : 1, e && e(f), f >= 1 && (t(), o = r(), i && ++s >= i))
+        return T();
+      u = P(l);
+    }
+  }
+  function K(y) {
+    y || N(), o = r() - (y ? f * n : 0), c = false, u = P(l);
+  }
+  function T() {
+    c = true;
+  }
+  function z() {
+    o = r(), f = 0, e && e(f);
+  }
+  function N() {
+    u && cancelAnimationFrame(u), f = 0, u = 0, c = true;
+  }
+  function R(y) {
+    n = y;
+  }
+  function V() {
+    return c;
+  }
+  return {
+    start: K,
+    rewind: z,
+    pause: T,
+    cancel: N,
+    set: R,
+    isPaused: V
+  };
+}
+function zn(n) {
+  let t = n;
+  function e(r) {
+    t = r;
+  }
+  function i(r) {
+    return G(L(r), t);
+  }
+  return { set: e, is: i };
+}
+function Rn(n, t) {
+  const e = sn(t || 0, n, void 0, 1);
+  return () => {
+    e.isPaused() && e.start();
+  };
+}
 
 function empty(array) {
   array.length = 0;
@@ -158,10 +217,6 @@ const nextTick = setTimeout;
 const noop = () => {
 };
 
-function raf(func) {
-  return requestAnimationFrame(func);
-}
-
 function typeOf(type, subject) {
   return typeof subject === type;
 }
@@ -998,83 +1053,6 @@ function Slides(Splide2, Components2, options, event) {
   };
 }
 
-function RequestInterval(interval, onInterval, onUpdate, limit) {
-  const { now } = Date;
-  let startTime;
-  let rate = 0;
-  let id;
-  let paused = true;
-  let count = 0;
-  function update() {
-    if (!paused) {
-      rate = interval ? min((now() - startTime) / interval, 1) : 1;
-      onUpdate && onUpdate(rate);
-      if (rate >= 1) {
-        onInterval();
-        startTime = now();
-        if (limit && ++count >= limit) {
-          return pause();
-        }
-      }
-      id = raf(update);
-    }
-  }
-  function start(resume) {
-    resume || cancel();
-    startTime = now() - (resume ? rate * interval : 0);
-    paused = false;
-    id = raf(update);
-  }
-  function pause() {
-    paused = true;
-  }
-  function rewind() {
-    startTime = now();
-    rate = 0;
-    if (onUpdate) {
-      onUpdate(rate);
-    }
-  }
-  function cancel() {
-    id && cancelAnimationFrame(id);
-    rate = 0;
-    id = 0;
-    paused = true;
-  }
-  function set(time) {
-    interval = time;
-  }
-  function isPaused() {
-    return paused;
-  }
-  return {
-    start,
-    rewind,
-    pause,
-    cancel,
-    set,
-    isPaused
-  };
-}
-
-function State(initialState) {
-  let state = initialState;
-  function set(value) {
-    state = value;
-  }
-  function is(states) {
-    return includes(toArray(states), state);
-  }
-  return { set, is };
-}
-
-function Throttle(func, duration) {
-  const interval = RequestInterval(duration || 0, func, null, 1);
-  return () => {
-    interval.isPaused() && interval.start();
-  };
-}
-
 function Layout(Splide2, Components2, options, event) {
   const { on, bind, emit } = event;
   const { Slides } = Components2;
@@ -1086,7 +1064,7 @@ function Layout(Splide2, Components2, options, event) {
   let overflow;
   function mount() {
     init();
-    bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE)));
+    bind(window, "resize load", Rn(apply(emit, EVENT_RESIZE)));
     on([EVENT_UPDATED, EVENT_REFRESH], init);
     on(EVENT_RESIZE, resize);
   }
@@ -1647,7 +1625,7 @@ const INTERVAL_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-interval`;
 
 function Autoplay(Splide2, Components2, options, event) {
   const { on, bind, emit } = event;
-  const interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
+  const interval = sn(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
   const { isPaused } = interval;
   const { Elements, Elements: { root, toggle } } = Components2;
   const { autoplay } = options;
@@ -1785,7 +1763,7 @@ function Scroll(Splide2, Components2, options, event) {
     friction = 1;
     duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
     callback = onScrolled;
-    interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
+    interval = sn(duration, onEnd, apply(update, from, destination, noConstrain), 1);
     set(SCROLLING);
     emit(EVENT_SCROLL);
     interval.start();
@@ -2354,7 +2332,7 @@ function Live(Splide2, Components2, options, event) {
   const { track } = Components2.Elements;
   const enabled = options.live && !options.isNavigation;
   const sr = create("span", CLASS_SR);
-  const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
+  const interval = sn(SR_REMOVAL_DELAY, apply(toggle, false));
   function mount() {
     if (enabled) {
       disable(!Components2.Autoplay.isPaused());
@@ -2536,7 +2514,7 @@ class Splide {
   root;
   event = fn();
   Components = {};
-  state = State(CREATED);
+  state = zn(CREATED);
   splides = [];
   _o = {};
   _C;
@@ -3087,12 +3065,9 @@ exports.FADE = FADE;
 exports.LOOP = LOOP;
 exports.LTR = LTR;
 exports.RTL = RTL;
-exports.RequestInterval = RequestInterval;
 exports.SLIDE = SLIDE;
 exports.STATUS_CLASSES = STATUS_CLASSES;
 exports.Splide = Splide;
 exports.SplideRenderer = SplideRenderer;
-exports.State = State;
 exports.TTB = TTB;
-exports.Throttle = Throttle;
 exports["default"] = Splide;

+ 66 - 88
dist/js/splide.esm.js

@@ -33,6 +33,9 @@ function m(n, t, e) {
 function a(n) {
   return n.bind(null, ...m(arguments, 1));
 }
+function P(n) {
+  return requestAnimationFrame(n);
+}
 function p(n, t) {
   return typeof t === n;
 }
@@ -49,6 +52,9 @@ function L(n) {
 function d(n, t) {
   L(n).forEach(t);
 }
+function G(n, t) {
+  return n.includes(t);
+}
 const b = Object.assign, A = Object.keys;
 function O(n, t, e) {
   return n && (e ? A(n).reverse() : A(n)).forEach((i) => {
@@ -67,7 +73,7 @@ function _() {
 function on(n, t) {
   return t = $(t) || !g(t) ? { class: _(t) } : t, `<${`${n} ${t ? rn(t) : ""}`.trim()}>`;
 }
-a(on, "div");
+a(on, "div"); const { min: E, max: w, floor: xn, ceil: Dn, abs: un, sign: Fn } = Math;
 function C(n, t) {
   d(n, (e) => {
     h(e) && e.split(" ").forEach(t);
@@ -136,6 +142,59 @@ function fn(n = H(), t = v()) {
   }
   return b({}, n, t, { create: e, destroy: i });
 }
+function sn(n, t, e, i) {
+  const { now: r } = Date;
+  let o, f = 0, u, c = true, s = 0;
+  function l() {
+    if (!c) {
+      if (f = n ? E((r() - o) / n, 1) : 1, e && e(f), f >= 1 && (t(), o = r(), i && ++s >= i))
+        return T();
+      u = P(l);
+    }
+  }
+  function K(y) {
+    y || N(), o = r() - (y ? f * n : 0), c = false, u = P(l);
+  }
+  function T() {
+    c = true;
+  }
+  function z() {
+    o = r(), f = 0, e && e(f);
+  }
+  function N() {
+    u && cancelAnimationFrame(u), f = 0, u = 0, c = true;
+  }
+  function R(y) {
+    n = y;
+  }
+  function V() {
+    return c;
+  }
+  return {
+    start: K,
+    rewind: z,
+    pause: T,
+    cancel: N,
+    set: R,
+    isPaused: V
+  };
+}
+function zn(n) {
+  let t = n;
+  function e(r) {
+    t = r;
+  }
+  function i(r) {
+    return G(L(r), t);
+  }
+  return { set: e, is: i };
+}
+function Rn(n, t) {
+  const e = sn(t || 0, n, void 0, 1);
+  return () => {
+    e.isPaused() && e.start();
+  };
+}
 
 function empty(array) {
   array.length = 0;
@@ -154,10 +213,6 @@ const nextTick = setTimeout;
 const noop = () => {
 };
 
-function raf(func) {
-  return requestAnimationFrame(func);
-}
-
 function typeOf(type, subject) {
   return typeof subject === type;
 }
@@ -994,83 +1049,6 @@ function Slides(Splide2, Components2, options, event) {
   };
 }
 
-function RequestInterval(interval, onInterval, onUpdate, limit) {
-  const { now } = Date;
-  let startTime;
-  let rate = 0;
-  let id;
-  let paused = true;
-  let count = 0;
-  function update() {
-    if (!paused) {
-      rate = interval ? min((now() - startTime) / interval, 1) : 1;
-      onUpdate && onUpdate(rate);
-      if (rate >= 1) {
-        onInterval();
-        startTime = now();
-        if (limit && ++count >= limit) {
-          return pause();
-        }
-      }
-      id = raf(update);
-    }
-  }
-  function start(resume) {
-    resume || cancel();
-    startTime = now() - (resume ? rate * interval : 0);
-    paused = false;
-    id = raf(update);
-  }
-  function pause() {
-    paused = true;
-  }
-  function rewind() {
-    startTime = now();
-    rate = 0;
-    if (onUpdate) {
-      onUpdate(rate);
-    }
-  }
-  function cancel() {
-    id && cancelAnimationFrame(id);
-    rate = 0;
-    id = 0;
-    paused = true;
-  }
-  function set(time) {
-    interval = time;
-  }
-  function isPaused() {
-    return paused;
-  }
-  return {
-    start,
-    rewind,
-    pause,
-    cancel,
-    set,
-    isPaused
-  };
-}
-
-function State(initialState) {
-  let state = initialState;
-  function set(value) {
-    state = value;
-  }
-  function is(states) {
-    return includes(toArray(states), state);
-  }
-  return { set, is };
-}
-
-function Throttle(func, duration) {
-  const interval = RequestInterval(duration || 0, func, null, 1);
-  return () => {
-    interval.isPaused() && interval.start();
-  };
-}
-
 function Layout(Splide2, Components2, options, event) {
   const { on, bind, emit } = event;
   const { Slides } = Components2;
@@ -1082,7 +1060,7 @@ function Layout(Splide2, Components2, options, event) {
   let overflow;
   function mount() {
     init();
-    bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE)));
+    bind(window, "resize load", Rn(apply(emit, EVENT_RESIZE)));
     on([EVENT_UPDATED, EVENT_REFRESH], init);
     on(EVENT_RESIZE, resize);
   }
@@ -1643,7 +1621,7 @@ const INTERVAL_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-interval`;
 
 function Autoplay(Splide2, Components2, options, event) {
   const { on, bind, emit } = event;
-  const interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
+  const interval = sn(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
   const { isPaused } = interval;
   const { Elements, Elements: { root, toggle } } = Components2;
   const { autoplay } = options;
@@ -1781,7 +1759,7 @@ function Scroll(Splide2, Components2, options, event) {
     friction = 1;
     duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
     callback = onScrolled;
-    interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
+    interval = sn(duration, onEnd, apply(update, from, destination, noConstrain), 1);
     set(SCROLLING);
     emit(EVENT_SCROLL);
     interval.start();
@@ -2350,7 +2328,7 @@ function Live(Splide2, Components2, options, event) {
   const { track } = Components2.Elements;
   const enabled = options.live && !options.isNavigation;
   const sr = create("span", CLASS_SR);
-  const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
+  const interval = sn(SR_REMOVAL_DELAY, apply(toggle, false));
   function mount() {
     if (enabled) {
       disable(!Components2.Autoplay.isPaused());
@@ -2532,7 +2510,7 @@ class Splide {
   root;
   event = fn();
   Components = {};
-  state = State(CREATED);
+  state = zn(CREATED);
   splides = [];
   _o = {};
   _C;
@@ -3018,4 +2996,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_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, RequestInterval, SLIDE, STATUS_CLASSES, Splide, SplideRenderer, State, TTB, Throttle, 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_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 };

+ 65 - 87
dist/js/splide.js

@@ -39,6 +39,9 @@
   function a(n) {
     return n.bind(null, ...m(arguments, 1));
   }
+  function P(n) {
+    return requestAnimationFrame(n);
+  }
   function p(n, t) {
     return typeof t === n;
   }
@@ -55,6 +58,9 @@
   function d(n, t) {
     L(n).forEach(t);
   }
+  function G(n, t) {
+    return n.includes(t);
+  }
   const b = Object.assign, A = Object.keys;
   function O(n, t, e) {
     return n && (e ? A(n).reverse() : A(n)).forEach((i) => {
@@ -73,7 +79,7 @@
   function on(n, t) {
     return t = $(t) || !g(t) ? { class: _(t) } : t, `<${`${n} ${t ? rn(t) : ""}`.trim()}>`;
   }
-  a(on, "div");
+  a(on, "div"); const { min: E, max: w, floor: xn, ceil: Dn, abs: un, sign: Fn } = Math;
   function C(n, t) {
     d(n, (e) => {
       h(e) && e.split(" ").forEach(t);
@@ -142,6 +148,59 @@
     }
     return b({}, n, t, { create: e, destroy: i });
   }
+  function sn(n, t, e, i) {
+    const { now: r } = Date;
+    let o, f = 0, u, c = true, s = 0;
+    function l() {
+      if (!c) {
+        if (f = n ? E((r() - o) / n, 1) : 1, e && e(f), f >= 1 && (t(), o = r(), i && ++s >= i))
+          return T();
+        u = P(l);
+      }
+    }
+    function K(y) {
+      y || N(), o = r() - (y ? f * n : 0), c = false, u = P(l);
+    }
+    function T() {
+      c = true;
+    }
+    function z() {
+      o = r(), f = 0, e && e(f);
+    }
+    function N() {
+      u && cancelAnimationFrame(u), f = 0, u = 0, c = true;
+    }
+    function R(y) {
+      n = y;
+    }
+    function V() {
+      return c;
+    }
+    return {
+      start: K,
+      rewind: z,
+      pause: T,
+      cancel: N,
+      set: R,
+      isPaused: V
+    };
+  }
+  function zn(n) {
+    let t = n;
+    function e(r) {
+      t = r;
+    }
+    function i(r) {
+      return G(L(r), t);
+    }
+    return { set: e, is: i };
+  }
+  function Rn(n, t) {
+    const e = sn(t || 0, n, void 0, 1);
+    return () => {
+      e.isPaused() && e.start();
+    };
+  }
 
   function empty(array) {
     array.length = 0;
@@ -160,10 +219,6 @@
   const noop = () => {
   };
 
-  function raf(func) {
-    return requestAnimationFrame(func);
-  }
-
   function typeOf(type, subject) {
     return typeof subject === type;
   }
@@ -993,83 +1048,6 @@
     };
   }
 
-  function RequestInterval(interval, onInterval, onUpdate, limit) {
-    const { now } = Date;
-    let startTime;
-    let rate = 0;
-    let id;
-    let paused = true;
-    let count = 0;
-    function update() {
-      if (!paused) {
-        rate = interval ? min((now() - startTime) / interval, 1) : 1;
-        onUpdate && onUpdate(rate);
-        if (rate >= 1) {
-          onInterval();
-          startTime = now();
-          if (limit && ++count >= limit) {
-            return pause();
-          }
-        }
-        id = raf(update);
-      }
-    }
-    function start(resume) {
-      resume || cancel();
-      startTime = now() - (resume ? rate * interval : 0);
-      paused = false;
-      id = raf(update);
-    }
-    function pause() {
-      paused = true;
-    }
-    function rewind() {
-      startTime = now();
-      rate = 0;
-      if (onUpdate) {
-        onUpdate(rate);
-      }
-    }
-    function cancel() {
-      id && cancelAnimationFrame(id);
-      rate = 0;
-      id = 0;
-      paused = true;
-    }
-    function set(time) {
-      interval = time;
-    }
-    function isPaused() {
-      return paused;
-    }
-    return {
-      start,
-      rewind,
-      pause,
-      cancel,
-      set,
-      isPaused
-    };
-  }
-
-  function State(initialState) {
-    let state = initialState;
-    function set(value) {
-      state = value;
-    }
-    function is(states) {
-      return includes(toArray(states), state);
-    }
-    return { set, is };
-  }
-
-  function Throttle(func, duration) {
-    const interval = RequestInterval(duration || 0, func, null, 1);
-    return () => {
-      interval.isPaused() && interval.start();
-    };
-  }
-
   function Layout(Splide2, Components2, options, event) {
     const { on, bind, emit } = event;
     const { Slides } = Components2;
@@ -1081,7 +1059,7 @@
     let overflow;
     function mount() {
       init();
-      bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE)));
+      bind(window, "resize load", Rn(apply(emit, EVENT_RESIZE)));
       on([EVENT_UPDATED, EVENT_REFRESH], init);
       on(EVENT_RESIZE, resize);
     }
@@ -1642,7 +1620,7 @@
 
   function Autoplay(Splide2, Components2, options, event) {
     const { on, bind, emit } = event;
-    const interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
+    const interval = sn(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame);
     const { isPaused } = interval;
     const { Elements, Elements: { root, toggle } } = Components2;
     const { autoplay } = options;
@@ -1780,7 +1758,7 @@
       friction = 1;
       duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION);
       callback = onScrolled;
-      interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1);
+      interval = sn(duration, onEnd, apply(update, from, destination, noConstrain), 1);
       set(SCROLLING);
       emit(EVENT_SCROLL);
       interval.start();
@@ -2349,7 +2327,7 @@
     const { track } = Components2.Elements;
     const enabled = options.live && !options.isNavigation;
     const sr = create("span", CLASS_SR);
-    const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
+    const interval = sn(SR_REMOVAL_DELAY, apply(toggle, false));
     function mount() {
       if (enabled) {
         disable(!Components2.Autoplay.isPaused());
@@ -2531,7 +2509,7 @@
     root;
     event = fn();
     Components = {};
-    state = State(CREATED);
+    state = zn(CREATED);
     splides = [];
     _o = {};
     _C;

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


+ 18 - 61
dist/types/index.d.ts

@@ -92,6 +92,22 @@ interface EventInterface<M extends Record<string, AnyFunction$1> = Record<string
  */
 declare function EventInterface<M extends Record<string, AnyFunction$1> = Record<string, AnyFunction$1>>(binder?: EventBinder, bus?: EventBus<Record<string, AnyFunction$1>>): EventInterface<M>;
 
+/**
+ * The interface for the State object.
+ *
+ * @since 0.0.1
+ */
+interface State {
+    set(state: number): void;
+    is(states: number | number[]): boolean;
+}
+/**
+ * The function providing a super simple state system.
+ *
+ * @param initialState - Specifies the initial state.
+ */
+declare function State(initialState: number): State;
+
 /**
  * The interface for the Media component.
  *
@@ -918,65 +934,6 @@ declare type SlidesPredicate = (Slide: SlideComponent, index: number, Slides: Sl
  */
 declare type SlideMatcher = number | number[] | string | SlidesPredicate;
 
-/**
- * The interface for the returning value of the RequestInterval.
- *
- * @since 3.0.0
- */
-interface RequestIntervalInterface {
-    start(resume?: boolean): void;
-    pause(): void;
-    rewind(): void;
-    cancel(): void;
-    set(interval: number): void;
-    isPaused(): boolean;
-}
-/**
- * Requests interval like the native `setInterval()` with using `requestAnimationFrame`.
- *
- * @since 3.0.0
- *
- * @param interval   - The interval duration in milliseconds.
- * @param onInterval - The callback fired on every interval.
- * @param onUpdate   - Optional. Called on every animation frame, taking the progress rate.
- * @param limit      - Optional. Limits the number of interval.
- */
-declare function RequestInterval(interval: number, onInterval: () => void, onUpdate?: (rate: number) => void, limit?: number): RequestIntervalInterface;
-
-/**
- * The interface for the State object.
- *
- * @since 3.0.0
- */
-interface StateObject {
-    set(state: number): void;
-    is(states: number | number[]): boolean;
-}
-/**
- * The function providing a super simple state system.
- *
- * @param initialState - Specifies the initial state.
- */
-declare function State(initialState: number): StateObject;
-
-/**
- * The interface for the returning value of the RequestInterval.
- *
- * @since 3.0.0
- */
-interface ThrottleInstance<F extends AnyFunction> extends Function {
-    (...args: Parameters<F>): void;
-}
-/**
- * Returns the throttled function.
- *
- * @param func     - A function to throttle.
- * @param duration - Optional. Throttle duration in milliseconds.
- *
- * @return A throttled function.
- */
-declare function Throttle<F extends AnyFunction>(func: F, duration?: number): ThrottleInstance<F>;
-
 /**
  * The frontend class for the Splide slider.
  *
@@ -1014,7 +971,7 @@ declare class Splide {
     /**
      * The StateObject object.
      */
-    readonly state: StateObject;
+    readonly state: State;
     /**
      * An array with SyncTarget objects for splide instances to sync with.
      */
@@ -1730,4 +1687,4 @@ declare const LOOP = "loop";
  */
 declare const FADE = "fade";
 
-export { AnyFunction, ArrowsComponent, AutoplayComponent, BaseComponent, 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, CoverComponent, 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_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, EventMap, FADE, Head, KeyboardComponent, LOOP, LTR, LayoutComponent, LazyLoadComponent, LiveComponent, MediaComponent, MoveComponent, Options, PaginationComponent, PaginationData, PaginationItem, Push, RTL, RequestInterval, RequestIntervalInterface, Resolve, ResponsiveOptions, SLIDE, STATUS_CLASSES, ScrollComponent, Shift, ShiftN, SlideComponent, SlidesComponent, Splide, SplideRenderer, State, StateObject, SyncComponent, SyncTarget, TTB, Throttle, ThrottleInstance, TransitionComponent, WheelComponent, Splide as default };
+export { AnyFunction, ArrowsComponent, AutoplayComponent, BaseComponent, 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, CoverComponent, 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_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, EventMap, FADE, Head, KeyboardComponent, LOOP, LTR, LayoutComponent, LazyLoadComponent, LiveComponent, MediaComponent, 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 };

+ 1 - 2
src/js/components/Autoplay/Autoplay.ts

@@ -12,8 +12,7 @@ import { Splide } from '../../core/Splide/Splide';
 import { BaseComponent, Components, Options } from '../../types';
 import { getAttribute, setAttribute, style, toggleClass } from '../../utils';
 import { INTERVAL_DATA_ATTRIBUTE } from './constants';
-import { RequestInterval } from '../../constructors';
-import { EventInterface } from '@splidejs/utils';
+import { EventInterface, RequestInterval } from '@splidejs/utils';
 
 
 /**

+ 1 - 2
src/js/components/Layout/Layout.ts

@@ -1,12 +1,11 @@
 import { TTB } from '../../constants/directions';
 import { EVENT_OVERFLOW, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_UPDATED } from '../../constants/events';
-import { Throttle } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
 import { BaseComponent, Components, Options } from '../../types';
 import { abs, apply, assert, isObject, rect, style, toggleClass, unit } from '../../utils';
 import { FADE } from '../../constants/types';
 import { CLASS_OVERFLOW } from '../../constants/classes';
-import { EventInterface } from '@splidejs/utils';
+import { EventInterface, Throttle } from '@splidejs/utils';
 
 
 /**

+ 1 - 2
src/js/components/Live/Live.ts

@@ -1,11 +1,10 @@
 import { ARIA_ATOMIC, ARIA_BUSY, ARIA_LIVE } from '../../constants/attributes';
 import { CLASS_SR } from '../../constants/classes';
 import { EVENT_AUTOPLAY_PAUSE, EVENT_AUTOPLAY_PLAY, EVENT_MOVED, EVENT_SCROLLED } from '../../constants/events';
-import { RequestInterval } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
 import { BaseComponent, Components, Options } from '../../types';
 import { append, apply, create, remove, removeAttribute, setAttribute } from '../../utils';
-import { EventInterface } from '@splidejs/utils';
+import { EventInterface, RequestInterval } from '@splidejs/utils';
 
 
 /**

+ 2 - 3
src/js/components/Scroll/Scroll.ts

@@ -1,12 +1,11 @@
 import { EVENT_MOVE, EVENT_REFRESH, EVENT_SCROLL, EVENT_SCROLLED, EVENT_UPDATED } from '../../constants/events';
 import { IDLE, SCROLLING } from '../../constants/states';
 import { SLIDE } from '../../constants/types';
-import { RequestInterval, RequestIntervalInterface } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
 import { AnyFunction, BaseComponent, Components, Options } from '../../types';
 import { abs, apply, approximatelyEqual, floor, max, sign } from '../../utils';
 import { BASE_VELOCITY, BOUNCE_DIFF_THRESHOLD, BOUNCE_DURATION, FRICTION_FACTOR, MIN_DURATION } from './constants';
-import { EventInterface } from '@splidejs/utils';
+import { EventInterface, RequestInterval } from '@splidejs/utils';
 
 
 /**
@@ -46,7 +45,7 @@ export function Scroll(
   /**
    * Retains the active RequestInterval object.
    */
-  let interval: RequestIntervalInterface;
+  let interval: RequestInterval;
 
   /**
    * Holds the callback function.

+ 0 - 153
src/js/constructors/EventBinder/EventBinder.ts

@@ -1,153 +0,0 @@
-import { AnyFunction } from '../../types';
-import { empty, forEach } from '../../utils';
-
-
-/**
- * The type for an EventTarget or an array with EventTarget objects.
- *
- * @since 4.0.0
- */
-type EventTargets = EventTarget | EventTarget[];
-
-/**
- * The interface for the EventBinder object.
- *
- * @since 3.0.0
- */
-export interface EventBinderObject {
-  bind( target: EventTargets, events: string | string[], callback: AnyFunction, options?: AddEventListenerOptions ): void
-  unbind( target: EventTarget | EventTarget[], events: string | string[], callback?: AnyFunction ): void;
-  dispatch<T>( target: EventTarget, event: string, detail?: T ): void;
-  destroy(): void;
-}
-
-/**
- * The constructor function to provide methods to subscribe native events.
- *
- * @since 4.0.0
- * @constructor
- *
- * @return An EventBinder object.
- */
-export function EventBinder(): EventBinderObject {
-  /**
-   * Stores all handlers that listen to native events.
-   * `[ target, event, namespace, callback, remover ]`
-   */
-  let listeners: [ EventTarget, string, string | undefined, AnyFunction, () => void ][] = [];
-
-  /**
-   * Listens to native events.
-   * - `destroy()` can unsubscribe all events.
-   * - In IE, mediaQueryList does not inherit EventTarget,
-   *   and only supports deprecated `addListener` and `removeListener`.
-   *
-   * @link https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
-   *
-   * @param targets  - A target element, the window object or the document object.
-   * @param events   - An event or events to listen to.
-   * @param callback - A callback function.
-   * @param options  - Optional. The options to pass to the `addEventListener` function.
-   */
-  function bind(
-    targets: EventTargets,
-    events: string | string[],
-    callback: AnyFunction,
-    options?: AddEventListenerOptions
-  ): void {
-    forEachEvent( targets, events, ( target, event, namespace ) => {
-      const isEventTarget = 'addEventListener' in target;
-      const remover = isEventTarget
-        ? target.removeEventListener.bind( target, event, callback, options )
-        : target[ 'removeListener' ].bind( target, callback );
-
-      isEventTarget ? target.addEventListener( event, callback, options ) : target[ 'addListener' ]( callback );
-      listeners.push( [ target, event, namespace, callback, remover ] );
-    } );
-  }
-
-  /**
-   * Removes the event handler.
-   *
-   * @param targets  - A target element, the window object or the document object.
-   * @param events   - An event name or names to remove.
-   * @param callback - Optional. Specify the callback to remove.
-   */
-  function unbind( targets: EventTargets, events: string | string[], callback?: AnyFunction ): void {
-    forEachEvent( targets, events, ( target, event, namespace ) => {
-      listeners = listeners.filter( listener => {
-        if ( listener[ 0 ] === target
-          && listener[ 1 ] === event
-          && listener[ 2 ] === namespace
-          && ( ! callback || listener[ 3 ] === callback )
-        ) {
-          listener[ 4 ]();
-          return false;
-        }
-
-        return true;
-      } );
-    } );
-  }
-
-  /**
-   * Dispatches a custom event of the target.
-   *
-   * @param target - An event target.
-   * @param type   - An event type.
-   * @param detail - Optional. The `detail` object of the event.
-   *
-   * @return An event object.
-   */
-  function dispatch<T>( target: EventTarget, type: string, detail?: T ): CustomEvent {
-    let e: CustomEvent;
-    const bubbles = true;
-
-    if ( typeof CustomEvent === 'function' ) {
-      e = new CustomEvent( type, { bubbles, detail } );
-    } else {
-      e = document.createEvent( 'CustomEvent' );
-      e.initCustomEvent( type, bubbles, false, detail );
-    }
-
-    target.dispatchEvent( e );
-    return e;
-  }
-
-  /**
-   * Iterates over each target and event.
-   *
-   * @param targets  - A target element, the window object or the document object.
-   * @param events   - An event name or names.
-   * @param iteratee - An iteratee function.
-   */
-  function forEachEvent(
-    targets: EventTargets,
-    events: string | string[],
-    iteratee: ( target: EventTarget, event: string, namespace: string | undefined ) => void
-  ): void {
-    forEach( targets, target => {
-      target && forEach( events, events => {
-        events.split( ' ' ).forEach( eventNS => {
-          const fragment = eventNS.split( '.' );
-          iteratee( target, fragment[ 0 ], fragment[ 1 ] );
-        } );
-      } );
-    } );
-  }
-
-  /**
-   * Removes all listeners.
-   */
-  function destroy(): void {
-    listeners.forEach( data => { data[ 4 ]() } );
-    empty( listeners );
-  }
-
-  return {
-    bind,
-    unbind,
-    dispatch,
-    destroy,
-  };
-}

+ 0 - 77
src/js/constructors/EventBinder/test/bind.test.ts

@@ -1,77 +0,0 @@
-import { fire } from '../../../test';
-import { EventBinder } from '../EventBinder';
-
-
-describe( 'EventBinder#bind()', () => {
-  const div = document.createElement( 'div' );
-
-  test( 'can listen to native events.', () => {
-    const { bind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-
-    bind( window, 'resize', callback1 );
-    bind( div, 'click', callback2 );
-
-    fire( window, 'resize' );
-    fire( div, 'click' );
-
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-  } );
-
-  test( 'can accept multiple events separated by spaces.', () => {
-    const { bind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, 'load resize click', callback );
-
-    fire( div, 'resize' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-  } );
-
-  test( 'can accept multiple events as an array.', () => {
-    const { bind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, [ 'load', 'resize', 'click' ], callback );
-
-    fire( div, 'resize' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-  } );
-
-  test( 'can accept multiple events by spaces and an array.', () => {
-    const { bind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, [ 'load resize click', 'scroll', 'wheel' ], callback );
-
-    fire( div, 'resize' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'scroll' );
-    expect( callback ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can accept a namespace by a dot notation.', () => {
-    const { bind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, [ 'load.namespace', 'resize.namespace', 'click.namespace' ], callback );
-
-    fire( div, 'resize' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-  } );
-} );

+ 0 - 46
src/js/constructors/EventBinder/test/destroy.test.ts

@@ -1,46 +0,0 @@
-import { fire } from '../../../test';
-import { EventBinder } from '../EventBinder';
-
-
-describe( 'EventBinder#destroy()', () => {
-  const div = document.createElement( 'div' );
-
-  test( 'can remove all listeners.', () => {
-    const { bind, destroy } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-
-    bind( window, 'resize', callback1 );
-    bind( div, 'click', callback2 );
-
-    destroy();
-
-    fire( window, 'resize' );
-    fire( div, 'click' );
-
-    expect( callback1 ).not.toHaveBeenCalled();
-    expect( callback2 ).not.toHaveBeenCalled();
-  } );
-
-  test( 'should not remove listeners bound by other binders.', () => {
-    const binder1 = EventBinder();
-    const binder2 = EventBinder();
-    const binder3 = EventBinder();
-
-    const binder1Callback = jest.fn();
-    const binder2Callback = jest.fn();
-    const binder3Callback = jest.fn();
-
-    binder1.bind( div, 'click', binder1Callback );
-    binder2.bind( div, 'click', binder2Callback );
-    binder3.bind( div, 'click', binder3Callback );
-
-    binder2.destroy();
-
-    fire( div, 'click' );
-
-    expect( binder1Callback ).toHaveBeenCalled();
-    expect( binder2Callback ).not.toHaveBeenCalled();
-    expect( binder3Callback ).toHaveBeenCalled();
-  } );
-} );

+ 0 - 33
src/js/constructors/EventBinder/test/dispatch.test.ts

@@ -1,33 +0,0 @@
-import { EventBinder } from '../EventBinder';
-
-
-describe( 'EventBinder#dispatch()', () => {
-  const div = document.createElement( 'div' );
-
-  test( 'can dispatch a custom event.', () => {
-    const { dispatch } = EventBinder();
-    const callback = jest.fn();
-
-    div.addEventListener( 'myEvent', callback );
-    dispatch( div, 'myEvent' );
-    expect( callback ).toHaveBeenCalled();
-  } );
-
-  test( 'can dispatch a custom event with a detail property.', done => {
-    const { dispatch } = EventBinder();
-    const array = [ 1, 2 ];
-
-    div.addEventListener( 'myEvent', e => {
-      if ( e instanceof CustomEvent ) {
-        expect( e.detail.a ).toBe( 1 );
-        expect( e.detail.b ).toBe( 'b' );
-        expect( e.detail.c ).toBe( array ); // Reference
-        done();
-      } else {
-        fail();
-      }
-    } );
-
-    dispatch( div, 'myEvent', { a: 1, b: 'b', c: array } );
-  } );
-} );

+ 0 - 231
src/js/constructors/EventBinder/test/unbind.test.ts

@@ -1,231 +0,0 @@
-import { fire } from '../../../test';
-import { EventBinder } from '../EventBinder';
-
-
-describe( 'EventBinder#unbind()', () => {
-  const div = document.createElement( 'div' );
-
-  test( 'can remove a listener.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-
-    bind( div, 'click', callback1 );
-    bind( div, 'mouseenter', callback2 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, 'click' );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 2 );
-
-    expect( callback2 ).not.toHaveBeenCalled();
-  } );
-
-  test( 'can remove multiple listeners by a string.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, 'click mouseenter mouseleave', callback );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, 'click mouseleave' );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseleave' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can remove multiple listeners by an array.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, 'click mouseenter mouseleave', callback );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, [ 'click', 'mouseleave' ] );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseleave' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can remove multiple listeners by a string and an array.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback = jest.fn();
-
-    bind( div, 'click mouseenter mouseleave mousemove', callback );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, [ 'click mousemove', 'mouseleave' ] );
-
-    fire( div, 'click' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseleave' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mousemove' );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    fire( div, 'mouseenter' );
-    expect( callback ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can only remove events that belong to the specified namespace.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-    const callback3 = jest.fn();
-
-    bind( div, 'click.namespace1', callback1 );
-    bind( div, 'click.namespace2', callback2 );
-    bind( div, 'click.namespace3', callback3 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-    expect( callback3 ).toHaveBeenCalledTimes( 1 );
-
-    unbind( div, 'click.namespace1' );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, 'click.namespace2' );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-
-    unbind( div, 'click.namespace3' );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can remove all handlers in the same namespace.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-    const callback3 = jest.fn();
-
-    bind( div, 'click.namespace', callback1 );
-    bind( div, 'click.namespace', callback2 );
-    bind( div, 'click.namespace', callback3 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-    expect( callback3 ).toHaveBeenCalledTimes( 1 );
-
-    unbind( div, 'click.namespace' );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-    expect( callback3 ).toHaveBeenCalledTimes( 1 );
-  } );
-
-  test( 'can only remove the specified callback.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-    const callback3 = jest.fn();
-
-    bind( div, 'click', callback1 );
-    bind( div, 'click', callback2 );
-    bind( div, 'click', callback3 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-    expect( callback3 ).toHaveBeenCalledTimes( 1 );
-
-    unbind( div, 'click', callback1 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, 'click', callback2 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-
-    unbind( div, 'click', callback3 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can only remove the specified callback in the same namespace.', () => {
-    const { bind, unbind } = EventBinder();
-    const callback1 = jest.fn();
-    const callback2 = jest.fn();
-    const callback3 = jest.fn();
-
-    bind( div, 'click.namespace', callback1 );
-    bind( div, 'click.namespace', callback2 );
-    bind( div, 'click.namespace', callback3 );
-
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 1 );
-    expect( callback3 ).toHaveBeenCalledTimes( 1 );
-
-    unbind( div, 'click.namespace', callback1 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 2 );
-
-    unbind( div, 'click.namespace', callback2 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-
-    unbind( div, 'click.namespace', callback3 );
-    fire( div, 'click' );
-    expect( callback1 ).toHaveBeenCalledTimes( 1 );
-    expect( callback2 ).toHaveBeenCalledTimes( 2 );
-    expect( callback3 ).toHaveBeenCalledTimes( 3 );
-  } );
-} );

+ 0 - 149
src/js/constructors/RequestInterval/RequestInterval.ts

@@ -1,149 +0,0 @@
-import { min, raf } from '../../utils';
-
-
-/**
- * The interface for the returning value of the RequestInterval.
- *
- * @since 3.0.0
- */
-export interface RequestIntervalInterface {
-  start( resume?: boolean ): void;
-  pause(): void;
-  rewind(): void;
-  cancel(): void;
-  set( interval: number ): void;
-  isPaused(): boolean;
-}
-
-/**
- * Requests interval like the native `setInterval()` with using `requestAnimationFrame`.
- *
- * @since 3.0.0
- *
- * @param interval   - The interval duration in milliseconds.
- * @param onInterval - The callback fired on every interval.
- * @param onUpdate   - Optional. Called on every animation frame, taking the progress rate.
- * @param limit      - Optional. Limits the number of interval.
- */
-export function RequestInterval(
-  interval: number,
-  onInterval: () => void,
-  onUpdate?: ( rate: number ) => void,
-  limit?: number
-): RequestIntervalInterface {
-  const { now } = Date;
-
-  /**
-   * The time when the interval starts.
-   */
-  let startTime: number;
-
-  /**
-   * The current progress rate.
-   */
-  let rate = 0;
-
-  /**
-   * The animation frame ID.
-   */
-  let id: number;
-
-  /**
-   * Indicates whether the interval is currently paused or not.
-   */
-  let paused = true;
-
-  /**
-   * The loop count. This only works when the `limit` argument is provided.
-   */
-  let count = 0;
-
-  /**
-   * The update function called on every animation frame.
-   */
-  function update(): void {
-    if ( ! paused ) {
-      rate = interval ? min( ( now() - startTime ) / interval, 1 ) : 1;
-      onUpdate && onUpdate( rate );
-
-      if ( rate >= 1 ) {
-        onInterval();
-        startTime = now();
-
-        if ( limit && ++count >= limit ) {
-          return pause();
-        }
-      }
-
-      id = raf( update );
-    }
-  }
-
-  /**
-   * Starts the interval.
-   *
-   * @param resume - Optional. Whether to resume the paused progress or not.
-   */
-  function start( resume?: boolean ): void {
-    resume || cancel();
-    startTime = now() - ( resume ? rate * interval : 0 );
-    paused    = false;
-    id        = raf( update );
-  }
-
-  /**
-   * Pauses the interval.
-   */
-  function pause(): void {
-    paused = true;
-  }
-
-  /**
-   * Rewinds the current progress.
-   */
-  function rewind(): void {
-    startTime = now();
-    rate      = 0;
-
-    if ( onUpdate ) {
-      onUpdate( rate );
-    }
-  }
-
-  /**
-   * Cancels the interval.
-   */
-  function cancel() {
-    id && cancelAnimationFrame( id );
-    rate   = 0;
-    id     = 0;
-    paused = true;
-  }
-
-  /**
-   * Sets new interval duration.
-   *
-   * @param time - The interval duration in milliseconds.
-   */
-  function set( time: number ): void {
-    interval = time;
-  }
-
-  /**
-   * Checks if the interval is paused or not.
-   *
-   * @return `true` if the interval is paused, or otherwise `false`.
-   */
-  function isPaused(): boolean {
-    return paused;
-  }
-
-  return {
-    start,
-    rewind,
-    pause,
-    cancel,
-    set,
-    isPaused,
-  };
-}

+ 0 - 122
src/js/constructors/RequestInterval/test/general.test.ts

@@ -1,122 +0,0 @@
-import { wait } from '../../../test';
-import { RequestInterval } from '../RequestInterval';
-
-
-describe( 'RequestInterval', () => {
-  test( 'can invoke a function repeatedly by the specified interval.', async () => {
-    const callback          = jest.fn();
-    const duration          = 1000;
-    const durationAndBuffer = 1100;
-    const interval          = RequestInterval( duration, callback );
-
-    interval.start();
-
-    expect( callback ).not.toHaveBeenCalled();
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 3 );
-  } );
-
-  test( 'can cancel the active interval.', async () => {
-    const callback          = jest.fn();
-    const duration          = 1000;
-    const durationAndBuffer = 1100;
-    const interval          = RequestInterval( duration, callback );
-
-    interval.start();
-
-    expect( callback ).not.toHaveBeenCalled();
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    interval.cancel();
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-  } );
-
-  test( 'can pause/resume the active interval.', async () => {
-    const callback          = jest.fn();
-    const duration          = 1000;
-    const durationAndBuffer = 1100;
-    const interval          = RequestInterval( duration, callback );
-
-    interval.start();
-
-    expect( callback ).not.toHaveBeenCalled();
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-    interval.pause();
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-
-    interval.start( true );
-
-    await wait( durationAndBuffer );
-    expect( callback ).toHaveBeenCalledTimes( 2 );
-  } );
-
-  test( 'can rewind the active interval.', async () => {
-    const callback = jest.fn();
-    const duration = 1000;
-    const buffer   = 100;
-    const interval = RequestInterval( duration, callback );
-
-    interval.start();
-
-    expect( callback ).not.toHaveBeenCalled();
-
-    // Rewind the interval timer around 900ms
-    await wait( duration - buffer );
-    interval.rewind();
-
-    // Now around 1100ms, but the callback should not be called.
-    await wait( buffer * 2 );
-    expect( callback ).not.toHaveBeenCalled();
-
-    // Around 1200ms after calling `rewind()`. The rewound timer should be expired.
-    await wait( duration );
-    expect( callback ).toHaveBeenCalledTimes( 1 );
-  } );
-
-  test( 'can check if the interval is paused or not.', () => {
-    const callback = jest.fn();
-    const duration = 1000;
-    const interval = RequestInterval( duration, callback );
-
-    expect( interval.isPaused() ).toBe( true );
-
-    interval.start();
-    expect( interval.isPaused() ).toBe( false );
-
-    interval.pause();
-    expect( interval.isPaused() ).toBe( true );
-
-    interval.start();
-    expect( interval.isPaused() ).toBe( false );
-
-    interval.cancel();
-    expect( interval.isPaused() ).toBe( true );
-  } );
-
-  test( 'should pause the interval after reaching the limit.', async () => {
-    const callback = jest.fn();
-    const duration = 1000;
-    const interval = RequestInterval( duration, callback, null, 1 );
-
-    await wait( duration + 100 );
-    expect( interval.isPaused() ).toBe( true );
-  } );
-} );

+ 0 - 46
src/js/constructors/State/State.ts

@@ -1,46 +0,0 @@
-import { includes, toArray } from '../../utils';
-
-
-/**
- * The interface for the State object.
- *
- * @since 3.0.0
- */
-export interface StateObject {
-  set( state: number ): void;
-  is( states: number | number[] ): boolean;
-}
-
-/**
- * The function providing a super simple state system.
- *
- * @param initialState - Specifies the initial state.
- */
-export function State( initialState: number ): StateObject {
-  /**
-   * The current state.
-   */
-  let state = initialState;
-
-  /**
-   * Sets a new state.
-   *
-   * @param value - A new state value.
-   */
-  function set( value: number ): void {
-    state = value;
-  }
-
-  /**
-   * Checks if the current state matches the provided one.
-   *
-   * @param states - A state to check.
-   *
-   * @return `true` if the current state is the provided one.
-   */
-  function is( states: number | number[] ): boolean {
-    return includes( toArray( states ), state );
-  }
-
-  return { set, is };
-}

+ 0 - 31
src/js/constructors/Throttle/Throttle.ts

@@ -1,31 +0,0 @@
-import { AnyFunction } from '../../types';
-import { RequestInterval } from '../RequestInterval/RequestInterval';
-
-
-/**
- * The interface for the returning value of the RequestInterval.
- *
- * @since 3.0.0
- */
-export interface ThrottleInstance<F extends AnyFunction> extends Function {
-  ( ...args: Parameters<F> ): void;
-}
-
-/**
- * Returns the throttled function.
- *
- * @param func     - A function to throttle.
- * @param duration - Optional. Throttle duration in milliseconds.
- *
- * @return A throttled function.
- */
-export function Throttle<F extends AnyFunction>(
-  func: F,
-  duration?: number
-): ThrottleInstance<F> {
-  const interval = RequestInterval( duration || 0, func, null, 1 );
-
-  return () => {
-    interval.isPaused() && interval.start();
-  };
-}

+ 0 - 39
src/js/constructors/Throttle/test/Throttle.test.ts

@@ -1,39 +0,0 @@
-import { Throttle } from '../Throttle';
-
-
-describe( 'Throttle', () => {
-  test( 'can control how often the callback function should be executed by the specified duration.', done => {
-    const callback  = jest.fn();
-    const duration  = 1000;
-    const throttled = Throttle( callback, duration );
-
-    throttled();
-    throttled();
-    throttled();
-    throttled();
-
-    expect( callback ).toHaveBeenCalledTimes( 0 );
-
-    // In the half way of the interval.
-    setTimeout( () => {
-      throttled();
-      throttled();
-      throttled();
-      throttled();
-
-      expect( callback ).toHaveBeenCalledTimes( 0 );
-    }, duration / 2 );
-
-    // After the interval duration.
-    setTimeout( () => {
-      throttled();
-      throttled();
-      throttled();
-      throttled();
-
-      expect( callback ).toHaveBeenCalledTimes( 1 );
-
-      done();
-    }, duration + 100 );
-  } );
-} );

+ 0 - 5
src/js/constructors/index.ts

@@ -1,5 +0,0 @@
-// export * from './EventBinder/EventBinder';
-// export * from './EventInterface/EventInterface';
-export * from './RequestInterval/RequestInterval';
-export * from './State/State';
-export * from './Throttle/Throttle';

+ 2 - 3
src/js/core/Splide/Splide.ts

@@ -6,12 +6,11 @@ import { EVENT_DESTROY, EVENT_MOUNTED, EVENT_READY, EVENT_REFRESH } from '../../
 import { DATA_ATTRIBUTE } from '../../constants/project';
 import { CREATED, DESTROYED, IDLE, STATES } from '../../constants/states';
 import { FADE } from '../../constants/types';
-import { State, StateObject } from '../../constructors';
 import { Fade, Slide } from '../../transitions';
 import { AnyFunction, ComponentConstructor, Components, EventMap, Options, SyncTarget } from '../../types';
 import { addClass, assert, assign, empty, forOwn, getAttribute, isString, merge, query, slice } from '../../utils';
 import { ARIA_LABEL, ARIA_LABELLEDBY } from '../../constants/attributes';
-import { EventInterface } from '@splidejs/utils';
+import { EventInterface, State } from '@splidejs/utils';
 
 
 /**
@@ -48,7 +47,7 @@ export class Splide {
   /**
    * The StateObject object.
    */
-  readonly state: StateObject = State( CREATED );
+  readonly state = State( CREATED );
 
   /**
    * An array with SyncTarget objects for splide instances to sync with.

+ 0 - 1
src/js/index.ts

@@ -2,7 +2,6 @@ export { Splide } from './core/Splide/Splide';
 export { Splide as default } from './core/Splide/Splide';
 export { SplideRenderer } from './renderer/SplideRenderer/SplideRenderer';
 export * from './components/types';
-export * from './constructors';
 export * from './types';
 export * from './constants/events';
 export * from './constants/classes';

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