Browse Source

Refactoring the event order.

NaotoshiFujita 3 năm trước cách đây
mục cha
commit
56c49610de

+ 11 - 9
dist/js/splide.cjs.js

@@ -378,6 +378,7 @@ const EVENT_REFRESH = "refresh";
 const EVENT_UPDATED = "updated";
 const EVENT_RESIZE = "resize";
 const EVENT_RESIZED = "resized";
+const EVENT_REPOSITIONED = "repositioned";
 const EVENT_DRAG = "drag";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGED = "dragged";
@@ -672,7 +673,7 @@ function Elements(Splide2, Components2, options) {
     addClass(root, classes = getClasses());
   }
   function mount() {
-    on(EVENT_REFRESH, refresh);
+    on(EVENT_REFRESH, refresh, DEFAULT_EVENT_PRIORITY - 2);
     on(EVENT_UPDATED, update);
   }
   function destroy() {
@@ -807,7 +808,7 @@ function Slide$1(Splide2, index, slideIndex, slide) {
     bind(slide, "click keydown", (e) => {
       emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, this, e);
     });
-    on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
+    on([EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], update.bind(this));
     if (updateOnMove) {
       on(EVENT_MOVE, onMove.bind(this));
     }
@@ -1187,13 +1188,15 @@ function Move(Splide2, Components2, options) {
   let waiting;
   function mount() {
     if (!Splide2.is(FADE)) {
-      on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
+      on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
+    } else {
+      emit(EVENT_REPOSITIONED);
     }
   }
   function reposition() {
     Components2.Scroll.cancel();
-    cancel(false);
     jump(Splide2.index);
+    emit(EVENT_REPOSITIONED);
   }
   function move(dest, index, prev, callback) {
     if (!isBusy()) {
@@ -1236,9 +1239,7 @@ function Move(Splide2, Components2, options) {
   function cancel(settle) {
     waiting = false;
     Components2.Transition.cancel();
-    if (settle) {
-      translate(getPosition());
-    }
+    translate(getPosition());
   }
   function toIndex(position) {
     const Slides = Components2.Slides.get();
@@ -1314,7 +1315,7 @@ function Controller(Splide2, Components2, options) {
   let perPage;
   function mount() {
     init();
-    on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 2);
+    on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 1);
     on(EVENT_SCROLLED, reindex, 0);
   }
   function init() {
@@ -1757,7 +1758,7 @@ function Drag(Splide2, Components2, options) {
           clickPrevented = false;
           bind(target, POINTER_MOVE_EVENTS, onPointerMove);
           bind(target, POINTER_UP_EVENTS, onPointerUp);
-          Move.cancel(true);
+          Move.cancel();
           Scroll.cancel();
           save(e);
         } else {
@@ -2802,6 +2803,7 @@ exports.EVENT_PAGINATION_MOUNTED = EVENT_PAGINATION_MOUNTED;
 exports.EVENT_PAGINATION_UPDATED = EVENT_PAGINATION_UPDATED;
 exports.EVENT_READY = EVENT_READY;
 exports.EVENT_REFRESH = EVENT_REFRESH;
+exports.EVENT_REPOSITIONED = EVENT_REPOSITIONED;
 exports.EVENT_RESIZE = EVENT_RESIZE;
 exports.EVENT_RESIZED = EVENT_RESIZED;
 exports.EVENT_SCROLL = EVENT_SCROLL;

+ 11 - 10
dist/js/splide.esm.js

@@ -374,6 +374,7 @@ const EVENT_REFRESH = "refresh";
 const EVENT_UPDATED = "updated";
 const EVENT_RESIZE = "resize";
 const EVENT_RESIZED = "resized";
+const EVENT_REPOSITIONED = "repositioned";
 const EVENT_DRAG = "drag";
 const EVENT_DRAGGING = "dragging";
 const EVENT_DRAGGED = "dragged";
@@ -668,7 +669,7 @@ function Elements(Splide2, Components2, options) {
     addClass(root, classes = getClasses());
   }
   function mount() {
-    on(EVENT_REFRESH, refresh);
+    on(EVENT_REFRESH, refresh, DEFAULT_EVENT_PRIORITY - 2);
     on(EVENT_UPDATED, update);
   }
   function destroy() {
@@ -803,7 +804,7 @@ function Slide$1(Splide2, index, slideIndex, slide) {
     bind(slide, "click keydown", (e) => {
       emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, this, e);
     });
-    on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
+    on([EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], update.bind(this));
     if (updateOnMove) {
       on(EVENT_MOVE, onMove.bind(this));
     }
@@ -1183,13 +1184,15 @@ function Move(Splide2, Components2, options) {
   let waiting;
   function mount() {
     if (!Splide2.is(FADE)) {
-      on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
+      on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
+    } else {
+      emit(EVENT_REPOSITIONED);
     }
   }
   function reposition() {
     Components2.Scroll.cancel();
-    cancel(false);
     jump(Splide2.index);
+    emit(EVENT_REPOSITIONED);
   }
   function move(dest, index, prev, callback) {
     if (!isBusy()) {
@@ -1232,9 +1235,7 @@ function Move(Splide2, Components2, options) {
   function cancel(settle) {
     waiting = false;
     Components2.Transition.cancel();
-    if (settle) {
-      translate(getPosition());
-    }
+    translate(getPosition());
   }
   function toIndex(position) {
     const Slides = Components2.Slides.get();
@@ -1310,7 +1311,7 @@ function Controller(Splide2, Components2, options) {
   let perPage;
   function mount() {
     init();
-    on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 2);
+    on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 1);
     on(EVENT_SCROLLED, reindex, 0);
   }
   function init() {
@@ -1753,7 +1754,7 @@ function Drag(Splide2, Components2, options) {
           clickPrevented = false;
           bind(target, POINTER_MOVE_EVENTS, onPointerMove);
           bind(target, POINTER_UP_EVENTS, onPointerUp);
-          Move.cancel(true);
+          Move.cancel();
           Scroll.cancel();
           save(e);
         } else {
@@ -2750,4 +2751,4 @@ class SplideRenderer {
   }
 }
 
-export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_AUTOPLAY, CLASS_CLONE, CLASS_CONTAINER, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PAUSE, CLASS_PLAY, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SLIDER, CLASS_SPINNER, CLASS_TRACK, CLASS_VISIBLE, 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_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, EventBus, EventInterface, RequestInterval, STATUS_CLASSES, Splide, SplideRenderer, State, Throttle, Splide as default };
+export { CLASSES, CLASS_ACTIVE, CLASS_ARROW, CLASS_ARROWS, CLASS_ARROW_NEXT, CLASS_ARROW_PREV, CLASS_AUTOPLAY, CLASS_CLONE, CLASS_CONTAINER, CLASS_INITIALIZED, CLASS_LIST, CLASS_LOADING, CLASS_NEXT, CLASS_PAGINATION, CLASS_PAGINATION_PAGE, CLASS_PAUSE, CLASS_PLAY, CLASS_PREV, CLASS_PROGRESS, CLASS_PROGRESS_BAR, CLASS_ROOT, CLASS_SLIDE, CLASS_SLIDER, CLASS_SPINNER, CLASS_TRACK, CLASS_VISIBLE, 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_HIDDEN, EVENT_INACTIVE, EVENT_LAZYLOAD_LOADED, EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_NAVIGATION_MOUNTED, EVENT_PAGINATION_MOUNTED, EVENT_PAGINATION_UPDATED, EVENT_READY, EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_RESIZE, EVENT_RESIZED, EVENT_SCROLL, EVENT_SCROLLED, EVENT_SLIDE_KEYDOWN, EVENT_UPDATED, EVENT_VISIBLE, EventBus, EventInterface, RequestInterval, STATUS_CLASSES, Splide, SplideRenderer, State, Throttle, Splide as default };

+ 10 - 10
dist/js/splide.js

@@ -420,6 +420,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
   var EVENT_UPDATED = "updated";
   var EVENT_RESIZE = "resize";
   var EVENT_RESIZED = "resized";
+  var EVENT_REPOSITIONED = "repositioned";
   var EVENT_DRAG = "drag";
   var EVENT_DRAGGING = "dragging";
   var EVENT_DRAGGED = "dragged";
@@ -768,7 +769,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     }
 
     function mount() {
-      on(EVENT_REFRESH, refresh);
+      on(EVENT_REFRESH, refresh, DEFAULT_EVENT_PRIORITY - 2);
       on(EVENT_UPDATED, update);
     }
 
@@ -917,7 +918,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       bind(slide, "click keydown", function (e) {
         emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
       });
-      on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
+      on([EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], update.bind(this));
 
       if (updateOnMove) {
         on(EVENT_MOVE, onMove.bind(this));
@@ -1410,14 +1411,16 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
     function mount() {
       if (!Splide2.is(FADE)) {
-        on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
+        on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
+      } else {
+        emit(EVENT_REPOSITIONED);
       }
     }
 
     function reposition() {
       Components2.Scroll.cancel();
-      cancel(false);
       jump(Splide2.index);
+      emit(EVENT_REPOSITIONED);
     }
 
     function move(dest, index, prev, callback) {
@@ -1468,10 +1471,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     function cancel(settle) {
       waiting = false;
       Components2.Transition.cancel();
-
-      if (settle) {
-        translate(getPosition());
-      }
+      translate(getPosition());
     }
 
     function toIndex(position) {
@@ -1566,7 +1566,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
     function mount() {
       init();
-      on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 2);
+      on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 1);
       on(EVENT_SCROLLED, reindex, 0);
     }
 
@@ -2123,7 +2123,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
             clickPrevented = false;
             bind(target, POINTER_MOVE_EVENTS, onPointerMove);
             bind(target, POINTER_UP_EVENTS, onPointerUp);
-            Move.cancel(true);
+            Move.cancel();
             Scroll.cancel();
             save(e);
           } else {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/js/splide.js.map


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/js/splide.min.js


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


+ 1 - 1
dist/types/components/Controller/Controller.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["Controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI9E;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,EAAE,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAI,IAAI,CAAC;IACvF,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,OAAO,CAAE,WAAW,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACzC,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;IAChC,QAAQ,CAAE,IAAI,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACnC,OAAO,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,MAAM,CAAE,KAAK,EAAE,MAAM,GAAI,MAAM,CAAC;IAChC,QAAQ,IAAI,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,mBAAmB,CAqS1G"}
+{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["Controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,E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AAI,iBAAiB,CA6ItG"}

+ 1 - 1
dist/types/components/Move/Move.d.ts

@@ -9,7 +9,7 @@ export interface MoveComponent extends BaseComponent {
     move(dest: number, index: number, prev: number, callback?: AnyFunction): void;
     jump(index: number): void;
     translate(position: number): void;
-    cancel(settle?: boolean): void;
+    cancel(): void;
     toIndex(position: number): number;
     toPosition(index: number, trimming?: boolean): number;
     getPosition(): number;

+ 1 - 1
dist/types/components/Move/Move.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"Move.d.ts","sourceRoot":"","sources":["Move.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI9E;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAI,IAAI,CAAC;IAChF,IAAI,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;IAC5B,SAAS,CAAE,QAAQ,EAAE,MAAM,GAAI,IAAI,CAAC;IACpC,MAAM,CAAE,MAAM,CAAC,EAAE,OAAO,GAAI,IAAI,CAAC;IACjC,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAI,MAAM,CAAC;IACpC,UAAU,CAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACxD,WAAW,IAAI,MAAM,CAAC;IACtB,QAAQ,CAAE,GAAG,EAAE,OAAO,GAAI,MAAM,CAAC;IACjC,MAAM,IAAI,OAAO,CAAC;IAClB,aAAa,CAAE,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC;CACxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,aAAa,CAkP9F"}
+{"version":3,"file":"Move.d.ts","sourceRoot":"","sources":["Move.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI9E;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAI,IAAI,CAAC;IAChF,IAAI,CAAE,KAAK,EAAE,MAAM,GAAI,IAAI,CAAC;IAC5B,SAAS,CAAE,QAAQ,EAAE,MAAM,GAAI,IAAI,CAAC;IACpC,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAI,MAAM,CAAC;IACpC,UAAU,CAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAI,MAAM,CAAC;IACxD,WAAW,IAAI,MAAM,CAAC;IACtB,QAAQ,CAAE,GAAG,EAAE,OAAO,GAAI,MAAM,CAAC;IACjC,MAAM,IAAI,OAAO,CAAC;IAClB,aAAa,CAAE,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,OAAO,CAAC;CACxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAI,aAAa,CAkP9F"}

+ 1 - 0
dist/types/constants/events.d.ts

@@ -12,6 +12,7 @@ export declare const EVENT_REFRESH = "refresh";
 export declare const EVENT_UPDATED = "updated";
 export declare const EVENT_RESIZE = "resize";
 export declare const EVENT_RESIZED = "resized";
+export declare const EVENT_REPOSITIONED = "repositioned";
 export declare const EVENT_DRAG = "drag";
 export declare const EVENT_DRAGGING = "dragging";
 export declare const EVENT_DRAGGED = "dragged";

+ 1 - 1
dist/types/constants/events.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,WAAW,UAAuB,CAAC;AAChD,eAAO,MAAM,UAAU,SAAuB,CAAC;AAC/C,eAAO,MAAM,WAAW,UAAuB,CAAC;AAChD,eAAO,MAAM,WAAW,UAAuB,CAAC;AAChD,eAAO,MAAM,YAAY,WAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,aAAuB,CAAC;AACnD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,YAAY,WAAuB,CAAC;AACjD,eAAO,MAAM,mBAAmB,kBAAuB,CAAC;AACxD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,YAAY,WAAuB,CAAC;AACjD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,UAAU,SAAuB,CAAC;AAC/C,eAAO,MAAM,cAAc,aAAuB,CAAC;AACnD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,YAAY,WAAuB,CAAC;AACjD,eAAO,MAAM,cAAc,aAAuB,CAAC;AACnD,eAAO,MAAM,aAAa,YAAuB,CAAC;AAClD,eAAO,MAAM,oBAAoB,mBAAuB,CAAC;AACzD,eAAO,MAAM,oBAAoB,mBAAuB,CAAC;AACzD,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,uBAAuB,CAAC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D,eAAO,MAAM,mBAAmB,kBAAuB,CAAC;AACxD,eAAO,MAAM,sBAAsB,qBAAuB,CAAC;AAC3D,eAAO,MAAM,oBAAoB,mBAAuB,CAAC;AACzD,eAAO,MAAM,qBAAqB,oBAAuB,CAAC"}

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

@@ -72,8 +72,7 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
    */
   function mount(): void {
     init();
-    // jump( currIndex );
-    on( [ EVENT_UPDATED, EVENT_REFRESH ], init, DEFAULT_EVENT_PRIORITY - 2 );
+    on( [ EVENT_UPDATED, EVENT_REFRESH ], init, DEFAULT_EVENT_PRIORITY - 1 );
     on( EVENT_SCROLLED, reindex, 0 );
   }
 

+ 1 - 1
src/js/components/Drag/Drag.ts

@@ -130,7 +130,7 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
 
           bind( target, POINTER_MOVE_EVENTS, onPointerMove );
           bind( target, POINTER_UP_EVENTS, onPointerUp );
-          Move.cancel( true );
+          Move.cancel();
           Scroll.cancel();
           save( e );
         } else {

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

@@ -16,6 +16,7 @@ import {
   CLASS_TRACK,
 } from '../../constants/classes';
 import { EVENT_REFRESH, EVENT_UPDATED } from '../../constants/events';
+import { DEFAULT_EVENT_PRIORITY } from '../../constants/priority';
 import { PROJECT_CODE } from '../../constants/project';
 import { EventInterface } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
@@ -105,7 +106,7 @@ export function Elements( Splide: Splide, Components: Components, options: Optio
    * Called when the component is mounted.
    */
   function mount(): void {
-    on( EVENT_REFRESH, refresh );
+    on( EVENT_REFRESH, refresh, DEFAULT_EVENT_PRIORITY - 2 );
     on( EVENT_UPDATED, update );
   }
 

+ 8 - 9
src/js/components/Move/Move.ts

@@ -2,11 +2,10 @@ import {
   EVENT_MOUNTED,
   EVENT_MOVE,
   EVENT_MOVED,
-  EVENT_REFRESH,
+  EVENT_REFRESH, EVENT_REPOSITIONED,
   EVENT_RESIZED,
   EVENT_UPDATED,
 } from '../../constants/events';
-import { DEFAULT_EVENT_PRIORITY } from '../../constants/priority';
 import { IDLE, MOVING } from '../../constants/states';
 import { FADE, LOOP, SLIDE } from '../../constants/types';
 import { EventInterface } from '../../constructors';
@@ -24,7 +23,7 @@ export interface MoveComponent extends BaseComponent {
   move( dest: number, index: number, prev: number, callback?: AnyFunction ): void;
   jump( index: number ): void;
   translate( position: number ): void;
-  cancel( settle?: boolean ): void;
+  cancel(): void;
   toIndex( position: number ): number;
   toPosition( index: number, trimming?: boolean ): number;
   getPosition(): number;
@@ -60,18 +59,21 @@ export function Move( Splide: Splide, Components: Components, options: Options )
    */
   function mount(): void {
     if ( ! Splide.is( FADE ) ) {
-      on( [ EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH ], reposition, DEFAULT_EVENT_PRIORITY - 1 );
+      on( [ EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH ], reposition );
+    } else {
+      emit( EVENT_REPOSITIONED );
     }
   }
 
   /**
    * Repositions the slider.
    * This must be called before the Slide component checks the visibility.
+   * Do not call `cancel()` here because LazyLoad may emit resize while transitioning.
    */
   function reposition(): void {
     Components.Scroll.cancel();
-    cancel( false );
     jump( Splide.index );
+    emit( EVENT_REPOSITIONED );
   }
 
   /**
@@ -156,10 +158,7 @@ export function Move( Splide: Splide, Components: Components, options: Options )
   function cancel( settle?: boolean ): void {
     waiting = false;
     Components.Transition.cancel();
-
-    if ( settle ) {
-      translate( getPosition() );
-    }
+    translate( getPosition() );
   }
 
   /**

+ 2 - 2
src/js/components/Slides/Slide.ts

@@ -22,7 +22,7 @@ import {
   EVENT_INACTIVE,
   EVENT_MOVE,
   EVENT_MOVED,
-  EVENT_REFRESH,
+  EVENT_REFRESH, EVENT_REPOSITIONED,
   EVENT_RESIZED,
   EVENT_SCROLLED,
   EVENT_SLIDE_KEYDOWN,
@@ -101,7 +101,7 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
       emit( e.type === 'click' ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, this, e );
     } );
 
-    on( [ EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED ], update.bind( this ) );
+    on( [ EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED ], update.bind( this ) );
 
     if ( updateOnMove ) {
       on( EVENT_MOVE, onMove.bind( this ) );

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

@@ -12,6 +12,7 @@ export const EVENT_REFRESH            = 'refresh';
 export const EVENT_UPDATED            = 'updated';
 export const EVENT_RESIZE             = 'resize';
 export const EVENT_RESIZED            = 'resized';
+export const EVENT_REPOSITIONED       = 'repositioned';
 export const EVENT_DRAG               = 'drag';
 export const EVENT_DRAGGING           = 'dragging';
 export const EVENT_DRAGGED            = 'dragged';

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác