Ver Fonte

Rename the option.

Naotoshi Fujita há 2 anos atrás
pai
commit
8d040f626a

+ 4 - 4
dist/js/splide.cjs.js

@@ -1581,7 +1581,7 @@ function Controller(Splide2, Components2, options) {
   var _Components2$Slides = Components2.Slides,
       isEnough = _Components2$Slides.isEnough,
       getLength = _Components2$Slides.getLength;
-  var compact = options.compact;
+  var omitEnd = options.omitEnd;
   var isLoop = Splide2.is(LOOP);
   var isSlide = Splide2.is(SLIDE);
   var getNext = apply(getAdjacent, false);
@@ -1604,7 +1604,7 @@ function Controller(Splide2, Components2, options) {
     perMove = options.perMove;
     perPage = options.perPage;
     endIndex = getEnd();
-    var index = clamp(currIndex, 0, compact ? endIndex : slideCount - 1);
+    var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1);
 
     if (index !== currIndex) {
       currIndex = index;
@@ -1633,7 +1633,7 @@ function Controller(Splide2, Components2, options) {
   function scroll(destination, duration, snap, callback) {
     Components2.Scroll.scroll(destination, duration, snap, function () {
       var index = loop(Move.toIndex(getPosition()));
-      setIndex(compact ? min(index, endIndex) : index);
+      setIndex(omitEnd ? min(index, endIndex) : index);
       callback && callback();
     });
   }
@@ -1726,7 +1726,7 @@ function Controller(Splide2, Components2, options) {
   function getEnd() {
     var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage);
 
-    while (compact && end-- > 0) {
+    while (omitEnd && end-- > 0) {
       if (toPosition(slideCount - 1, true) !== toPosition(end, true)) {
         end++;
         break;

+ 4 - 4
dist/js/splide.esm.js

@@ -1576,7 +1576,7 @@ function Controller(Splide2, Components2, options) {
   var _Components2$Slides = Components2.Slides,
       isEnough = _Components2$Slides.isEnough,
       getLength = _Components2$Slides.getLength;
-  var compact = options.compact;
+  var omitEnd = options.omitEnd;
   var isLoop = Splide2.is(LOOP);
   var isSlide = Splide2.is(SLIDE);
   var getNext = apply(getAdjacent, false);
@@ -1599,7 +1599,7 @@ function Controller(Splide2, Components2, options) {
     perMove = options.perMove;
     perPage = options.perPage;
     endIndex = getEnd();
-    var index = clamp(currIndex, 0, compact ? endIndex : slideCount - 1);
+    var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1);
 
     if (index !== currIndex) {
       currIndex = index;
@@ -1628,7 +1628,7 @@ function Controller(Splide2, Components2, options) {
   function scroll(destination, duration, snap, callback) {
     Components2.Scroll.scroll(destination, duration, snap, function () {
       var index = loop(Move.toIndex(getPosition()));
-      setIndex(compact ? min(index, endIndex) : index);
+      setIndex(omitEnd ? min(index, endIndex) : index);
       callback && callback();
     });
   }
@@ -1721,7 +1721,7 @@ function Controller(Splide2, Components2, options) {
   function getEnd() {
     var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage);
 
-    while (compact && end-- > 0) {
+    while (omitEnd && end-- > 0) {
       if (toPosition(slideCount - 1, true) !== toPosition(end, true)) {
         end++;
         break;

+ 4 - 4
dist/js/splide.js

@@ -1574,7 +1574,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     var _Components2$Slides = Components2.Slides,
         isEnough = _Components2$Slides.isEnough,
         getLength = _Components2$Slides.getLength;
-    var compact = options.compact;
+    var omitEnd = options.omitEnd;
     var isLoop = Splide2.is(LOOP);
     var isSlide = Splide2.is(SLIDE);
     var getNext = apply(getAdjacent, false);
@@ -1597,7 +1597,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       perMove = options.perMove;
       perPage = options.perPage;
       endIndex = getEnd();
-      var index = clamp(currIndex, 0, compact ? endIndex : slideCount - 1);
+      var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1);
 
       if (index !== currIndex) {
         currIndex = index;
@@ -1626,7 +1626,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     function scroll(destination, duration, snap, callback) {
       Components2.Scroll.scroll(destination, duration, snap, function () {
         var index = loop(Move.toIndex(getPosition()));
-        setIndex(compact ? min(index, endIndex) : index);
+        setIndex(omitEnd ? min(index, endIndex) : index);
         callback && callback();
       });
     }
@@ -1719,7 +1719,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     function getEnd() {
       var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage);
 
-      while (compact && end-- > 0) {
+      while (omitEnd && end-- > 0) {
         if (toPosition(slideCount - 1, true) !== toPosition(end, true)) {
           end++;
           break;

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/js/splide.min.js


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


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/js/splide.min.js.map


+ 2 - 2
dist/types/index.d.ts

@@ -401,7 +401,7 @@ interface Options extends ResponsiveOptions {
     /**
      * Determines whether to trim spaces before/after the slider if the `focus` option is available.
      * - `true`: Trims spaces. The slider may stay on the same location even when requested to move.
-     * - `'move'`: Trims spaces and focuses to move the slider when requested.
+     * - `'move'`: Trims spaces and forces to move the slider when requested.
      */
     trimSpace?: boolean | 'move';
     /**
@@ -409,7 +409,7 @@ interface Options extends ResponsiveOptions {
      * - Disables the next arrow when a carousel reaches the last page even if the active slide is not the last slide.
      * - Omits redundant pagination dots which just change the active slide and do not move a carousel.
      */
-    compact?: boolean;
+    omitEnd?: boolean;
     /**
      * Updates the `is-active` status of slides just before moving the slider.
      */

+ 5 - 5
src/js/components/Controller/Controller.ts

@@ -46,7 +46,7 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
   const { Move } = Components;
   const { getPosition, getLimit, toPosition } = Move;
   const { isEnough, getLength } = Components.Slides;
-  const { compact } = options;
+  const { omitEnd } = options;
   const isLoop  = Splide.is( LOOP );
   const isSlide = Splide.is( SLIDE );
   const getNext = apply( getAdjacent, false );
@@ -102,7 +102,7 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
     perPage    = options.perPage;
     endIndex   = getEnd();
 
-    const index = clamp( currIndex, 0, compact ? endIndex : slideCount - 1 );
+    const index = clamp( currIndex, 0, omitEnd ? endIndex : slideCount - 1 );
 
     if ( index !== currIndex ) {
       currIndex = index;
@@ -152,7 +152,7 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
   function scroll( destination: number, duration?: number, snap?: boolean, callback?: AnyFunction ): void {
     Components.Scroll.scroll( destination, duration, snap, () => {
       const index = loop( Move.toIndex( getPosition() ) );
-      setIndex( compact ? min( index, endIndex ) : index );
+      setIndex( omitEnd ? min( index, endIndex ) : index );
       callback && callback();
     } );
   }
@@ -292,14 +292,14 @@ export function Controller( Splide: Splide, Components: Components, options: Opt
    * Returns the end index where the slider can go.
    * For example, if the slider has 10 slides and the `perPage` option is 3,
    * the slider can go to the slide 8 (the index is 7).
-   * If the `compact` option is available, computes the index from the slide position.
+   * If the `omitEnd` option is available, computes the index from the slide position.
    *
    * @return An end index.
    */
   function getEnd(): number {
     let end = slideCount - ( hasFocus() || ( isLoop && perMove ) ? 1 : perPage );
 
-    while ( compact && end-- > 0 ) {
+    while ( omitEnd && end-- > 0 ) {
       if ( toPosition( slideCount - 1, true ) !== toPosition( end, true ) ) {
         end++;
         break;

+ 2 - 2
src/js/components/Pagination/test/general.test.ts

@@ -26,8 +26,8 @@ describe( 'Pagination', () => {
     expect( items.length ).toBe( splide.length );
   } );
 
-  test( 'should omit unnecessary items when `focus` and `compact` options are enabled.', () => {
-    const splide = init( { perPage: 3, focus: 0, compact: true } );
+  test( 'should omit unnecessary items when `focus` and `omitEnd` options are enabled.', () => {
+    const splide = init( { perPage: 3, focus: 0, omitEnd: true } );
     const items  = document.getElementsByClassName( CLASS_PAGINATION_PAGE );
 
     expect( items.length ).not.toBe( splide.length );

+ 1 - 1
src/js/test/php/examples/autoWidth.php

@@ -23,7 +23,7 @@ $settings = get_settings();
         // trimSpace : tr,
         focus     : 0,
         drag      : 'free',
-        compact   : true,
+        omitEnd   : true,
       } );
 
       splide01.mount();

+ 2 - 2
src/js/test/php/examples/default.php

@@ -22,7 +22,7 @@ $settings = get_settings();
     document.addEventListener( 'DOMContentLoaded', function () {
       var splide = new Splide( '#splide01', {
         width: 800,
-        type        : 'loop',
+        // type        : 'loop',
         perPage: 2,
         // perMove: 3,
         // rewind: true,
@@ -36,7 +36,7 @@ $settings = get_settings();
         // role: '',
         label: 'Changed Label',
         focus: 0,
-        compact: true,
+        omitEnd: true,
 
         // breakpoints: {
         //   1200: {

+ 1 - 1
src/js/test/php/examples/fixedSize.php

@@ -22,7 +22,7 @@ $settings = get_settings();
         // type       : 'loop',
         fixedWidth : '6rem',
         gap        : 10,
-        compact    : true,
+        omitEnd    : true,
         focus      : 0,
       } );
 

+ 2 - 2
src/js/test/php/examples/overflow.php

@@ -21,7 +21,7 @@ $settings = get_settings();
       var splide01 = new Splide( '#splide01', {
         fixedWidth : '6rem',
         gap        : 10,
-        compact    : true,
+        omitEnd    : true,
         focus      : 0,
       } );
 
@@ -93,7 +93,7 @@ $settings = get_settings();
         gap       : '1rem',
         focus     : 0,
         drag      : 'free',
-        compact   : true,
+        omitEnd   : true,
       } );
 
       splide04.on( 'overflow', overflow => {

+ 1 - 1
src/js/types/options.ts

@@ -161,7 +161,7 @@ export interface Options extends ResponsiveOptions {
    * - Disables the next arrow when a carousel reaches the last page even if the active slide is not the last slide.
    * - Omits redundant pagination dots which just change the active slide and do not move a carousel.
    */
-  compact?: boolean;
+  omitEnd?: boolean;
 
   /**
    * Updates the `is-active` status of slides just before moving the slider.

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff