1
1
/*!
2
- * Glide.js v3.1 .0
2
+ * Glide.js v3.2 .0
3
3
* (c) 2013-2018 Jędrzej Chałubek <[email protected] > (http://jedrzejchalubek.com/)
4
4
* Released under the MIT License.
5
5
*/
@@ -566,7 +566,7 @@ var Glide = function () {
566
566
classCallCheck ( this , Glide ) ;
567
567
568
568
this . _c = { } ;
569
- this . _m = [ ] ;
569
+ this . _t = [ ] ;
570
570
this . _e = new EventsBus ( ) ;
571
571
572
572
this . disabled = false ;
@@ -602,19 +602,19 @@ var Glide = function () {
602
602
}
603
603
604
604
/**
605
- * Collects instance translate mutators .
605
+ * Collects an instance ` translate` transformers .
606
606
*
607
- * @param {Array } mutators Collection of mutators .
607
+ * @param {Array } transformers Collection of transformers .
608
608
* @return {Void }
609
609
*/
610
610
611
611
} , {
612
612
key : 'mutate' ,
613
613
value : function mutate ( ) {
614
- var mutators = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ ] ;
614
+ var transformers = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ ] ;
615
615
616
- if ( isArray ( mutators ) ) {
617
- this . _m = mutators ;
616
+ if ( isArray ( transformers ) ) {
617
+ this . _t = transformers ;
618
618
} else {
619
619
warn ( 'You need to provide a array on `mutate()`' ) ;
620
620
}
@@ -2282,15 +2282,15 @@ function Focusing (Glide, Components) {
2282
2282
* @param {Object } Components
2283
2283
* @return {Object }
2284
2284
*/
2285
- function transformer ( Glide , Components , Events ) {
2285
+ function mutator ( Glide , Components , Events ) {
2286
2286
/**
2287
- * Merge instance mutators with collection of default transformers.
2287
+ * Merge instance transformers with collection of default transformers.
2288
2288
* It's important that the Rtl component be last on the list,
2289
2289
* so it reflects all previous transformations.
2290
2290
*
2291
2291
* @type {Array }
2292
2292
*/
2293
- var MUTATORS = [ Gap , Grow , Peeking , Focusing ] . concat ( Glide . _m , [ Rtl ] ) ;
2293
+ var TRANSFORMERS = [ Gap , Grow , Peeking , Focusing ] . concat ( Glide . _t , [ Rtl ] ) ;
2294
2294
2295
2295
return {
2296
2296
/**
@@ -2300,8 +2300,14 @@ function transformer (Glide, Components, Events) {
2300
2300
* @return {Number }
2301
2301
*/
2302
2302
mutate : function mutate ( translate ) {
2303
- for ( var i = 0 ; i < MUTATORS . length ; i ++ ) {
2304
- translate = MUTATORS [ i ] ( Glide , Components , Events ) . modify ( translate ) ;
2303
+ for ( var i = 0 ; i < TRANSFORMERS . length ; i ++ ) {
2304
+ var transformer = TRANSFORMERS [ i ] ;
2305
+
2306
+ if ( isFunction ( transformer ) && isFunction ( transformer ( ) . modify ) ) {
2307
+ translate = transformer ( Glide , Components , Events ) . modify ( translate ) ;
2308
+ } else {
2309
+ warn ( 'Transformer should be a function that returns an object with `modify()` method' ) ;
2310
+ }
2305
2311
}
2306
2312
2307
2313
return translate ;
@@ -2318,7 +2324,7 @@ function Translate (Glide, Components, Events) {
2318
2324
* @return {Void }
2319
2325
*/
2320
2326
set : function set ( value ) {
2321
- var transform = transformer ( Glide , Components ) . mutate ( value ) ;
2327
+ var transform = mutator ( Glide , Components ) . mutate ( value ) ;
2322
2328
2323
2329
Components . Html . wrapper . style . transform = 'translate3d(' + - 1 * transform + 'px, 0px, 0px)' ;
2324
2330
} ,
0 commit comments