Bläddra i källkod

Remove the `cover` option and the `Cover` component. Use default parameters.

Naotoshi Fujita 2 år sedan
förälder
incheckning
5aff57ae60

+ 8 - 36
dist/js/splide.js

@@ -1195,8 +1195,7 @@
       const shifted = orient(shift(getPosition(), backwards));
       return backwards ? shifted >= padding : shifted <= list[resolve("scrollWidth")] - tn(track)[resolve("width")] + padding;
     }
-    function exceededLimit(max, position) {
-      position = Z(position) ? getPosition() : position;
+    function exceededLimit(max, position = getPosition()) {
       const exceededMin = max !== true && orient(position) < orient(getLimit(false));
       const exceededMax = max !== false && orient(position) > orient(getLimit(true));
       return exceededMin || exceededMax;
@@ -1571,32 +1570,6 @@
     };
   }
 
-  function Cover(Splide2, Components2, options, event) {
-    const { on } = event;
-    function mount() {
-      if (options.cover) {
-        on(EVENT_LAZYLOAD_LOADED, a(toggle, true));
-        on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], a(cover, true));
-      }
-    }
-    function cover(cover2) {
-      Components2.Slides.forEach((Slide) => {
-        const img = Y(Slide.container || Slide.slide, "img");
-        if (img && img.src) {
-          toggle(cover2, img, Slide);
-        }
-      });
-    }
-    function toggle(cover2, img, Slide) {
-      Slide.style("background", cover2 ? `center/cover no-repeat url("${img.src}")` : "", true);
-      An(img, cover2 ? "none" : "");
-    }
-    return {
-      mount,
-      destroy: a(cover, false)
-    };
-  }
-
   const BOUNCE_DIFF_THRESHOLD = 10;
   const BOUNCE_DURATION = 600;
   const FRICTION_FACTOR = 0.6;
@@ -2233,7 +2206,6 @@
     Controller: Controller,
     Arrows: Arrows,
     Autoplay: Autoplay,
-    Cover: Cover,
     Scroll: Scroll,
     Drag: Drag,
     Keyboard: Keyboard,
@@ -2372,14 +2344,14 @@
     _C;
     _E = {};
     _T;
-    constructor(target, options) {
+    constructor(target, options = {}) {
       const root = p(target) ? On(document, target) : target;
       assert(root, `${root} is invalid.`);
       this.root = root;
       options = k({
         label: wn(root, ARIA_LABEL) || "",
         labelledby: wn(root, ARIA_LABELLEDBY) || ""
-      }, DEFAULTS, Splide.defaults, options || {});
+      }, DEFAULTS, Splide.defaults, options);
       try {
         k(options, JSON.parse(wn(root, DATA_ATTRIBUTE)));
       } catch (e) {
@@ -2387,13 +2359,13 @@
       }
       this._o = Object.create(k({}, options));
     }
-    mount(Extensions, Transition) {
+    mount(Extensions = this._E, Transition = this._T) {
       const { state, Components: Components2 } = this;
       assert(state.is([CREATED, DESTROYED]), "Already mounted!");
       state.set(CREATED);
       this._C = Components2;
-      this._T = Transition || this._T || (this.is(FADE) ? Fade : Slide);
-      this._E = Extensions || this._E;
+      this._T = Transition || (this.is(FADE) ? Fade : Slide);
+      this._E = Extensions;
       const Constructors = v({}, ComponentConstructors, this._E, { Transition: this._T });
       L(Constructors, (Component, key) => {
         const component = Component(this, Components2, this._o, this.event.create());
@@ -2430,8 +2402,8 @@
       this.event.off(events, callback);
       return this;
     }
-    emit(event) {
-      this.event.emit(event, ...F(arguments, 1));
+    emit(event, ...args) {
+      this.event.emit(event, ...args);
       return this;
     }
     add(slides, index) {

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
dist/js/splide.min.js


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


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
dist/js/splide.min.js.map


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

@@ -11,7 +11,7 @@ import { IDLE, MOVING } from '../../constants/states';
 import { FADE, LOOP, SLIDE } from '../../constants/types';
 import { Splide } from '../../core/Splide/Splide';
 import { AnyFunction, BaseComponent, Components, Options, TransitionComponent } from '../../types';
-import { abs, ceil, clamp, EventInterface, isUndefined, rect, style } from '@splidejs/utils';
+import { abs, ceil, clamp, EventInterface, rect, style } from '@splidejs/utils';
 
 
 /**
@@ -289,8 +289,7 @@ export function Move(
    *
    * @return `true` if the position exceeds the limit, or otherwise `false`.
    */
-  function exceededLimit( max?: boolean | undefined, position?: number ): boolean {
-    position = isUndefined( position ) ? getPosition() : position;
+  function exceededLimit( max?: boolean | undefined, position = getPosition() ): boolean {
     const exceededMin = max !== true && orient( position ) < orient( getLimit( false ) );
     const exceededMax = max !== false && orient( position ) > orient( getLimit( true ) );
     return exceededMin || exceededMax;

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

@@ -8,7 +8,6 @@ export { Move }       from './Move/Move';
 export { Controller } from './Controller/Controller';
 export { Arrows }     from './Arrows/Arrows';
 export { Autoplay }   from './Autoplay/Autoplay';
-export { Cover }      from './Cover/Cover';
 export { Scroll }     from './Scroll/Scroll';
 export { Drag }       from './Drag/Drag';
 export { Keyboard }   from './Keyboard/Keyboard';
@@ -16,4 +15,4 @@ export { LazyLoad }   from './LazyLoad/LazyLoad';
 export { Pagination } from './Pagination/Pagination';
 export { Sync }       from './Sync/Sync';
 export { Wheel }      from './Wheel/Wheel';
-export { Live }       from './Live/Live';
+export { Live }       from './Live/Live';

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

@@ -9,7 +9,6 @@ export type { MoveComponent }       from './Move/Move';
 export type { ControllerComponent } from './Controller/Controller';
 export type { ArrowsComponent }     from './Arrows/Arrows';
 export type { AutoplayComponent }   from './Autoplay/Autoplay';
-export type { CoverComponent }      from './Cover/Cover';
 export type { ScrollComponent }     from './Scroll/Scroll';
 export type { DragComponent }       from './Drag/Drag';
 export type { KeyboardComponent }   from './Keyboard/Keyboard';

+ 7 - 8
src/js/core/Splide/Splide.ts

@@ -92,7 +92,7 @@ export class Splide {
    * @param target  - The selector for the target element, or the element itself.
    * @param options - Optional. An object with options.
    */
-  constructor( target: string | HTMLElement, options?: Options ) {
+  constructor( target: string | HTMLElement, options: Options = {} ) {
     const root = isString( target ) ? query<HTMLElement>( document, target ) : target;
     assert( root, `${ root } is invalid.` );
 
@@ -101,7 +101,7 @@ export class Splide {
     options = merge( {
       label     : getAttribute( root, ARIA_LABEL ) || '',
       labelledby: getAttribute( root, ARIA_LABELLEDBY ) || '',
-    }, DEFAULTS, Splide.defaults, options || {} );
+    }, DEFAULTS, Splide.defaults, options );
 
     try {
       merge( options, JSON.parse( getAttribute( root, DATA_ATTRIBUTE ) ) );
@@ -120,15 +120,15 @@ export class Splide {
    *
    * @return `this`
    */
-  mount( Extensions?: Record<string, ComponentConstructor>, Transition?: ComponentConstructor ): this {
+  mount( Extensions: Record<string, ComponentConstructor> = this._E, Transition: ComponentConstructor = this._T ): this {
     const { state, Components } = this;
     assert( state.is( [ CREATED, DESTROYED ] ), 'Already mounted!' );
 
     state.set( CREATED );
 
     this._C = Components;
-    this._T = Transition || this._T || ( this.is( FADE ) ? Fade : Slide );
-    this._E = Extensions || this._E;
+    this._T = Transition || ( this.is( FADE ) ? Fade : Slide );
+    this._E = Extensions;
 
     const Constructors = assign( {}, ComponentConstructors, this._E, { Transition: this._T } );
 
@@ -287,9 +287,8 @@ export class Splide {
    */
   emit<K extends keyof EventMap>( event: K, ...args: Parameters<EventMap[ K ]> ): this;
   emit( event: string, ...args: any[] ): this;
-  emit( event: string ): this {
-    // eslint-disable-next-line prefer-rest-params, prefer-spread
-    this.event.emit( event, ...slice( arguments, 1 ) );
+  emit( event: string, ...args: any[] ): this {
+    this.event.emit( event, ...args );
     return this;
   }
 

+ 0 - 6
src/js/types/options.ts

@@ -132,12 +132,6 @@ export interface Options extends ResponsiveOptions {
    */
   direction?: 'ltr' | 'rtl' | 'ttb';
 
-  /**
-   * Converts the image `src` to the css `background-image` URL of the parent element.
-   * This requires `fixedHeight` or `heightRatio` option.
-   */
-  cover?: boolean;
-
   /**
    * Determines whether to add `tabindex="0"` to visible slides or not.
    */

Vissa filer visades inte eftersom för många filer har ändrats