diff --git a/css/flickity.css b/css/flickity.css index f98e8188..82b2d306 100644 --- a/css/flickity.css +++ b/css/flickity.css @@ -1,4 +1,4 @@ -/*! Flickity v2.0.2 +/*! Flickity v2.0.3 http://flickity.metafizzy.co ---------------------------------------------- */ diff --git a/dist/flickity.css b/dist/flickity.css index f98e8188..82b2d306 100644 --- a/dist/flickity.css +++ b/dist/flickity.css @@ -1,4 +1,4 @@ -/*! Flickity v2.0.2 +/*! Flickity v2.0.3 http://flickity.metafizzy.co ---------------------------------------------- */ diff --git a/dist/flickity.min.css b/dist/flickity.min.css index 7765c64e..9b26e26b 100644 --- a/dist/flickity.min.css +++ b/dist/flickity.min.css @@ -1,4 +1,4 @@ -/*! Flickity v2.0.2 +/*! Flickity v2.0.3 http://flickity.metafizzy.co ---------------------------------------------- */ .flickity-enabled{position:relative}.flickity-enabled:focus{outline:0}.flickity-viewport{overflow:hidden;position:relative;height:100%}.flickity-slider{position:absolute;width:100%;height:100%}.flickity-enabled.is-draggable{-webkit-tap-highlight-color:transparent;tap-highlight-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.flickity-enabled.is-draggable .flickity-viewport{cursor:move;cursor:-webkit-grab;cursor:grab}.flickity-enabled.is-draggable .flickity-viewport.is-pointer-down{cursor:-webkit-grabbing;cursor:grabbing}.flickity-prev-next-button{position:absolute;top:50%;width:44px;height:44px;border:none;border-radius:50%;background:#fff;background:hsla(0,0%,100%,.75);cursor:pointer;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.flickity-prev-next-button:hover{background:#fff}.flickity-prev-next-button:focus{outline:0;box-shadow:0 0 0 5px #09F}.flickity-prev-next-button:active{opacity:.6}.flickity-prev-next-button.previous{left:10px}.flickity-prev-next-button.next{right:10px}.flickity-rtl .flickity-prev-next-button.previous{left:auto;right:10px}.flickity-rtl .flickity-prev-next-button.next{right:auto;left:10px}.flickity-prev-next-button:disabled{opacity:.3;cursor:auto}.flickity-prev-next-button svg{position:absolute;left:20%;top:20%;width:60%;height:60%}.flickity-prev-next-button .arrow{fill:#333}.flickity-page-dots{position:absolute;width:100%;bottom:-25px;padding:0;margin:0;list-style:none;text-align:center;line-height:1}.flickity-rtl .flickity-page-dots{direction:rtl}.flickity-page-dots .dot{display:inline-block;width:10px;height:10px;margin:0 8px;background:#333;border-radius:50%;opacity:.25;cursor:pointer}.flickity-page-dots .dot.is-selected{opacity:1} \ No newline at end of file diff --git a/dist/flickity.pkgd.js b/dist/flickity.pkgd.js index c5cbff6e..6670e471 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() { diff --git a/dist/flickity.pkgd.min.js b/dist/flickity.pkgd.min.js index c9ea64b5..15f2dc66 100644 --- a/dist/flickity.pkgd.min.js +++ b/dist/flickity.pkgd.min.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 @@ -9,5 +9,5 @@ * Copyright 2016 Metafizzy */ -!function(t,e){"use strict";"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,o,a){function h(t,e,n){var s,o="$()."+i+'("'+e+'")';return t.each(function(t,h){var l=a.data(h,i);if(!l)return void r(i+" not initialized. Cannot call methods, i.e. "+o);var c=l[e];if(!c||"_"==e.charAt(0))return void r(o+" is not a valid method");var d=c.apply(l,n);s=void 0===s?d:s}),void 0!==s?s:t}function l(t,e){t.each(function(t,n){var s=a.data(n,i);s?(s.option(e),s._init()):(s=new o(n,e),a.data(n,i,s))})}a=a||e||t.jQuery,a&&(o.prototype.option||(o.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=s.call(arguments,1);return h(this,t,e)}return l(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var s=Array.prototype.slice,o=t.console,r="undefined"==typeof o?function(){}:function(t){o.error(t)};return n(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return n.indexOf(e)==-1&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||{};return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return n!=-1&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,s=i[n];e=e||[];for(var o=this._onceEvents&&this._onceEvents[t];s;){var r=o&&o[s];r&&(this.off(t,s),delete o[s]),s.apply(this,e),n+=r?0:1,s=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=t.indexOf("%")==-1&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;e