diff options
Diffstat (limited to 'dist/flickity.pkgd.js')
-rw-r--r-- | dist/flickity.pkgd.js | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/dist/flickity.pkgd.js b/dist/flickity.pkgd.js index c5cbff6..6670e47 100644 --- a/dist/flickity.pkgd.js +++ b/dist/flickity.pkgd.js @@ -1,5 +1,5 @@ /*! - * Flickity PACKAGED v2.0.2 + * Flickity PACKAGED v2.0.3 * Touch, responsive, flickable carousels * * Licensed GPLv3 for open source use @@ -11,20 +11,19 @@ /** * Bridget makes jQuery widgets - * v2.0.0 + * v2.0.1 * MIT license */ /* jshint browser: true, strict: true, undef: true, unused: true */ ( function( window, factory ) { - 'use strict'; - /* globals define: false, module: false, require: false */ - + // universal module definition + /*jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) { - factory( window, jQuery ); + return factory( window, jQuery ); }); } else if ( typeof module == 'object' && module.exports ) { // CommonJS @@ -1228,6 +1227,13 @@ function Flickity( element, options ) { return; } this.element = queryElement; + // do not initialize twice on same element + if ( this.element.flickityGUID ) { + var instance = instances[ this.element.flickityGUID ]; + instance.option( options ); + return instance; + } + // add jQuery if ( jQuery ) { this.$element = jQuery( this.element ); @@ -2680,6 +2686,7 @@ proto._childUIPointerDownDrag = function( event ) { var cursorNodes = { TEXTAREA: true, INPUT: true, + OPTION: true, }; // input types that do not have text fields @@ -2693,7 +2700,7 @@ var clickTypes = { }; proto.pointerDown = function( event, pointer ) { - // dismiss inputs with text fields. #404 + // dismiss inputs with text fields. #403, #404 var isCursorInput = cursorNodes[ event.target.nodeName ] && !clickTypes[ event.target.type ]; if ( isCursorInput ) { @@ -3455,7 +3462,7 @@ proto._createPageDots = function() { this.on( 'resize', this.updatePageDots ); this.on( 'deactivate', this.deactivatePageDots ); - this.pageDots.on( 'pointerDown', function( button, event ) { + this.pageDots.on( 'pointerDown', function( event ) { this.childUIPointerDown( event ); }.bind( this )); }; @@ -4002,7 +4009,7 @@ return Flickity; })); /*! - * Flickity v2.0.2 + * Flickity v2.0.3 * Touch, responsive, flickable carousels * * Licensed GPLv3 for open source use @@ -4045,7 +4052,7 @@ return Flickity; }); /*! - * Flickity asNavFor v2.0.0 + * Flickity asNavFor v2.0.1 * enable asNavFor for Flickity */ @@ -4059,26 +4066,22 @@ return Flickity; define( 'flickity-as-nav-for/as-nav-for',[ 'flickity/js/index', 'fizzy-ui-utils/utils' - ], function( classie, Flickity, utils ) { - return factory( window, classie, Flickity, utils ); - }); + ], factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( - window, require('flickity'), require('fizzy-ui-utils') ); } else { // browser global window.Flickity = factory( - window, window.Flickity, window.fizzyUIUtils ); } -}( window, function factory( window, Flickity, utils ) { +}( window, function factory( Flickity, utils ) { @@ -4124,27 +4127,38 @@ proto.setNavCompanion = function( elem ) { // click this.on( 'staticClick', this.onNavStaticClick ); - this.navCompanionSelect(); + this.navCompanionSelect( true ); }; -proto.navCompanionSelect = function() { +proto.navCompanionSelect = function( isInstant ) { if ( !this.navCompanion ) { return; } // select slide that matches first cell of slide var selectedCell = this.navCompanion.selectedCells[0]; - var cellIndex = this.navCompanion.cells.indexOf( selectedCell ); - this.selectCell( cellIndex ); + var firstIndex = this.navCompanion.cells.indexOf( selectedCell ); + var lastIndex = firstIndex + this.navCompanion.selectedCells.length - 1; + var selectIndex = Math.floor( lerp( firstIndex, lastIndex, + this.navCompanion.cellAlign ) ); + this.selectCell( selectIndex, false, isInstant ); // set nav selected class this.removeNavSelectedElements(); // stop if companion has more cells than this one - if ( cellIndex >= this.cells.length ) { + if ( selectIndex >= this.cells.length ) { return; } - this.navSelectedElements = this.slides[ this.selectedIndex ].getCellElements(); + + var selectedCells = this.cells.slice( firstIndex, lastIndex + 1 ); + this.navSelectedElements = selectedCells.map( function( cell ) { + return cell.element; + }); this.changeNavSelectedClass('add'); }; +function lerp( a, b, t ) { + return ( b - a ) * t + a; +} + proto.changeNavSelectedClass = function( method ) { this.navSelectedElements.forEach( function( navElem ) { navElem.classList[ method ]('is-nav-selected'); @@ -4152,7 +4166,7 @@ proto.changeNavSelectedClass = function( method ) { }; proto.activateAsNavFor = function() { - this.navCompanionSelect(); + this.navCompanionSelect( true ); }; proto.removeNavSelectedElements = function() { |