1
1
/*!
2
- * Packery PACKAGED v2.1.1
2
+ * Packery PACKAGED v2.1.2
3
3
* Gapless, draggable grid layouts
4
4
*
5
5
* Licensed GPLv3 for open source use
6
6
* or Packery Commercial License for commercial use
7
7
*
8
8
* http://packery.metafizzy.co
9
- * Copyright 2016 Metafizzy
9
+ * Copyright 2013-2018 Metafizzy
10
10
*/
11
11
12
12
/**
13
13
* Bridget makes jQuery widgets
14
- * v2.0.0
14
+ * v2.0.1
15
15
* MIT license
16
16
*/
17
17
18
18
/* jshint browser: true, strict: true, undef: true, unused: true */
19
19
20
20
( function ( window , factory ) {
21
- 'use strict' ;
22
- /* globals define: false, module: false, require: false */
23
-
21
+ // universal module definition
22
+ /*jshint strict: false */ /* globals define, module, require */
24
23
if ( typeof define == 'function' && define . amd ) {
25
24
// AMD
26
25
define ( 'jquery-bridget/jquery-bridget' , [ 'jquery' ] , function ( jQuery ) {
27
- factory ( window , jQuery ) ;
26
+ return factory ( window , jQuery ) ;
28
27
} ) ;
29
28
} else if ( typeof module == 'object' && module . exports ) {
30
29
// CommonJS
@@ -155,22 +154,19 @@ return jQueryBridget;
155
154
} ) ) ;
156
155
157
156
/*!
158
- * getSize v2.0.2
157
+ * getSize v2.0.3
159
158
* measure size of elements
160
159
* MIT license
161
160
*/
162
161
163
- /*jshint browser: true, strict: true, undef: true, unused: true */
164
- /*global define: false, module: false, console: false */
162
+ /* jshint browser: true, strict: true, undef: true, unused: true */
163
+ /* globals console: false */
165
164
166
165
( function ( window , factory ) {
167
- 'use strict' ;
168
-
166
+ /* jshint strict: false */ /* globals define, module */
169
167
if ( typeof define == 'function' && define . amd ) {
170
168
// AMD
171
- define ( 'get-size/get-size' , [ ] , function ( ) {
172
- return factory ( ) ;
173
- } ) ;
169
+ define ( 'get-size/get-size' , factory ) ;
174
170
} else if ( typeof module == 'object' && module . exports ) {
175
171
// CommonJS
176
172
module . exports = factory ( ) ;
@@ -245,7 +241,7 @@ function getStyle( elem ) {
245
241
if ( ! style ) {
246
242
logError ( 'Style returned ' + style +
247
243
'. Are you running this code in a hidden iframe on Firefox? ' +
248
- 'See http ://bit.ly/getsizebug1' ) ;
244
+ 'See https ://bit.ly/getsizebug1' ) ;
249
245
}
250
246
return style ;
251
247
}
@@ -271,8 +267,8 @@ function setup() {
271
267
// -------------------------- box sizing -------------------------- //
272
268
273
269
/**
274
- * WebKit measures the outer-width on style.width on border-box elems
275
- * IE & Firefox<29 measures the inner-width
270
+ * Chrome & Safari measure the outer-width on style.width on border-box elems
271
+ * IE11 & Firefox<29 measures the inner-width
276
272
*/
277
273
var div = document . createElement ( 'div' ) ;
278
274
div . style . width = '200px' ;
@@ -284,10 +280,11 @@ function setup() {
284
280
var body = document . body || document . documentElement ;
285
281
body . appendChild ( div ) ;
286
282
var style = getStyle ( div ) ;
283
+ // round value for browser zoom. desandro/masonry#928
284
+ isBoxSizeOuter = Math . round ( getStyleSize ( style . width ) ) == 200 ;
285
+ getSize . isBoxSizeOuter = isBoxSizeOuter ;
287
286
288
- getSize . isBoxSizeOuter = isBoxSizeOuter = getStyleSize ( style . width ) == 200 ;
289
287
body . removeChild ( div ) ;
290
-
291
288
}
292
289
293
290
// -------------------------- getSize -------------------------- //
@@ -365,7 +362,7 @@ return getSize;
365
362
} ) ;
366
363
367
364
/**
368
- * EvEmitter v1.0.2
365
+ * EvEmitter v1.1.0
369
366
* Lil' event emitter
370
367
* MIT License
371
368
*/
@@ -374,7 +371,7 @@ return getSize;
374
371
375
372
( function ( global , factory ) {
376
373
// universal module definition
377
- /* jshint strict: false */ /* globals define, module */
374
+ /* jshint strict: false */ /* globals define, module, window */
378
375
if ( typeof define == 'function' && define . amd ) {
379
376
// AMD - RequireJS
380
377
define ( 'ev-emitter/ev-emitter' , factory ) ;
@@ -386,7 +383,7 @@ return getSize;
386
383
global . EvEmitter = factory ( ) ;
387
384
}
388
385
389
- } ( this , function ( ) {
386
+ } ( typeof window != 'undefined' ? window : this , function ( ) {
390
387
391
388
392
389
@@ -445,13 +442,14 @@ proto.emitEvent = function( eventName, args ) {
445
442
if ( ! listeners || ! listeners . length ) {
446
443
return ;
447
444
}
448
- var i = 0 ;
449
- var listener = listeners [ i ] ;
445
+ // copy over to avoid interference if .off() in listener
446
+ listeners = listeners . slice ( 0 ) ;
450
447
args = args || [ ] ;
451
448
// once stuff
452
449
var onceListeners = this . _onceEvents && this . _onceEvents [ eventName ] ;
453
450
454
- while ( listener ) {
451
+ for ( var i = 0 ; i < listeners . length ; i ++ ) {
452
+ var listener = listeners [ i ]
455
453
var isOnce = onceListeners && onceListeners [ listener ] ;
456
454
if ( isOnce ) {
457
455
// remove listener
@@ -462,20 +460,22 @@ proto.emitEvent = function( eventName, args ) {
462
460
}
463
461
// trigger listener
464
462
listener . apply ( this , args ) ;
465
- // get next listener
466
- i += isOnce ? 0 : 1 ;
467
- listener = listeners [ i ] ;
468
463
}
469
464
470
465
return this ;
471
466
} ;
472
467
468
+ proto . allOff = function ( ) {
469
+ delete this . _events ;
470
+ delete this . _onceEvents ;
471
+ } ;
472
+
473
473
return EvEmitter ;
474
474
475
475
} ) ) ;
476
476
477
477
/**
478
- * matchesSelector v2.0.1
478
+ * matchesSelector v2.0.2
479
479
* matchesSelector( element, '.selector' )
480
480
* MIT license
481
481
*/
@@ -501,7 +501,7 @@ return EvEmitter;
501
501
'use strict' ;
502
502
503
503
var matchesMethod = ( function ( ) {
504
- var ElemProto = Element . prototype ;
504
+ var ElemProto = window . Element . prototype ;
505
505
// check for the standard method name first
506
506
if ( ElemProto . matches ) {
507
507
return 'matches' ;
@@ -529,7 +529,7 @@ return EvEmitter;
529
529
} ) ) ;
530
530
531
531
/**
532
- * Fizzy UI utils v2.0.1
532
+ * Fizzy UI utils v2.0.7
533
533
* MIT license
534
534
*/
535
535
@@ -584,22 +584,27 @@ utils.modulo = function( num, div ) {
584
584
585
585
// ----- makeArray ----- //
586
586
587
+ var arraySlice = Array . prototype . slice ;
588
+
587
589
// turn element or nodeList into an array
588
590
utils . makeArray = function ( obj ) {
589
- var ary = [ ] ;
590
591
if ( Array . isArray ( obj ) ) {
591
592
// use object if already an array
592
- ary = obj ;
593
- } else if ( obj && typeof obj . length == 'number' ) {
593
+ return obj ;
594
+ }
595
+ // return empty array if undefined or null. #6
596
+ if ( obj === null || obj === undefined ) {
597
+ return [ ] ;
598
+ }
599
+
600
+ var isArrayLike = typeof obj == 'object' && typeof obj . length == 'number' ;
601
+ if ( isArrayLike ) {
594
602
// convert nodeList to array
595
- for ( var i = 0 ; i < obj . length ; i ++ ) {
596
- ary . push ( obj [ i ] ) ;
597
- }
598
- } else {
599
- // array of single index
600
- ary . push ( obj ) ;
603
+ return arraySlice . call ( obj ) ;
601
604
}
602
- return ary ;
605
+
606
+ // array of single index
607
+ return [ obj ] ;
603
608
} ;
604
609
605
610
// ----- removeFrom ----- //
@@ -614,7 +619,7 @@ utils.removeFrom = function( ary, obj ) {
614
619
// ----- getParent ----- //
615
620
616
621
utils . getParent = function ( elem , selector ) {
617
- while ( elem != document . body ) {
622
+ while ( elem . parentNode && elem != document . body ) {
618
623
elem = elem . parentNode ;
619
624
if ( matchesSelector ( elem , selector ) ) {
620
625
return elem ;
@@ -678,30 +683,31 @@ utils.filterFindElements = function( elems, selector ) {
678
683
// ----- debounceMethod ----- //
679
684
680
685
utils . debounceMethod = function ( _class , methodName , threshold ) {
686
+ threshold = threshold || 100 ;
681
687
// original method
682
688
var method = _class . prototype [ methodName ] ;
683
689
var timeoutName = methodName + 'Timeout' ;
684
690
685
691
_class . prototype [ methodName ] = function ( ) {
686
692
var timeout = this [ timeoutName ] ;
687
- if ( timeout ) {
688
- clearTimeout ( timeout ) ;
689
- }
690
- var args = arguments ;
693
+ clearTimeout ( timeout ) ;
691
694
695
+ var args = arguments ;
692
696
var _this = this ;
693
697
this [ timeoutName ] = setTimeout ( function ( ) {
694
698
method . apply ( _this , args ) ;
695
699
delete _this [ timeoutName ] ;
696
- } , threshold || 100 ) ;
700
+ } , threshold ) ;
697
701
} ;
698
702
} ;
699
703
700
704
// ----- docReady ----- //
701
705
702
706
utils . docReady = function ( callback ) {
703
- if ( document . readyState == 'complete' ) {
704
- callback ( ) ;
707
+ var readyState = document . readyState ;
708
+ if ( readyState == 'complete' || readyState == 'interactive' ) {
709
+ // do async to allow for other scripts to run. metafizzy/flickity#441
710
+ setTimeout ( callback ) ;
705
711
} else {
706
712
document . addEventListener ( 'DOMContentLoaded' , callback ) ;
707
713
}
@@ -749,7 +755,7 @@ utils.htmlInit = function( WidgetClass, namespace ) {
749
755
}
750
756
// initialize
751
757
var instance = new WidgetClass ( elem , options ) ;
752
- // make available via $().data('layoutname ')
758
+ // make available via $().data('namespace ')
753
759
if ( jQuery ) {
754
760
jQuery . data ( elem , namespace , instance ) ;
755
761
}
@@ -899,13 +905,16 @@ proto.getPosition = function() {
899
905
var isOriginTop = this . layout . _getOption ( 'originTop' ) ;
900
906
var xValue = style [ isOriginLeft ? 'left' : 'right' ] ;
901
907
var yValue = style [ isOriginTop ? 'top' : 'bottom' ] ;
908
+ var x = parseFloat ( xValue ) ;
909
+ var y = parseFloat ( yValue ) ;
902
910
// convert percent to pixels
903
911
var layoutSize = this . layout . size ;
904
- var x = xValue . indexOf ( '%' ) != - 1 ?
905
- ( parseFloat ( xValue ) / 100 ) * layoutSize . width : parseInt ( xValue , 10 ) ;
906
- var y = yValue . indexOf ( '%' ) != - 1 ?
907
- ( parseFloat ( yValue ) / 100 ) * layoutSize . height : parseInt ( yValue , 10 ) ;
908
-
912
+ if ( xValue . indexOf ( '%' ) != - 1 ) {
913
+ x = ( x / 100 ) * layoutSize . width ;
914
+ }
915
+ if ( yValue . indexOf ( '%' ) != - 1 ) {
916
+ y = ( y / 100 ) * layoutSize . height ;
917
+ }
909
918
// clean up 'auto' or other non-integer values
910
919
x = isNaN ( x ) ? 0 : x ;
911
920
y = isNaN ( y ) ? 0 : y ;
@@ -968,9 +977,7 @@ proto._transitionTo = function( x, y ) {
968
977
var curX = this . position . x ;
969
978
var curY = this . position . y ;
970
979
971
- var compareX = parseInt ( x , 10 ) ;
972
- var compareY = parseInt ( y , 10 ) ;
973
- var didNotMove = compareX === this . position . x && compareY === this . position . y ;
980
+ var didNotMove = x == this . position . x && y == this . position . y ;
974
981
975
982
// save end position
976
983
this . setPosition ( x , y ) ;
@@ -1013,8 +1020,8 @@ proto.goTo = function( x, y ) {
1013
1020
proto . moveTo = proto . _transitionTo ;
1014
1021
1015
1022
proto . setPosition = function ( x , y ) {
1016
- this . position . x = parseInt ( x , 10 ) ;
1017
- this . position . y = parseInt ( y , 10 ) ;
1023
+ this . position . x = parseFloat ( x ) ;
1024
+ this . position . y = parseFloat ( y ) ;
1018
1025
} ;
1019
1026
1020
1027
// ----- transition ----- //
@@ -1319,7 +1326,7 @@ return Item;
1319
1326
} ) ) ;
1320
1327
1321
1328
/*!
1322
- * Outlayer v2.1.0
1329
+ * Outlayer v2.1.1
1323
1330
* the brains and guts of a layout library
1324
1331
* MIT license
1325
1332
*/
@@ -2698,7 +2705,10 @@ proto.disablePlacing = function() {
2698
2705
2699
2706
// remove element from DOM
2700
2707
proto . removeElem = function ( ) {
2701
- this . element . parentNode . removeChild ( this . element ) ;
2708
+ var parent = this . element . parentNode ;
2709
+ if ( parent ) {
2710
+ parent . removeChild ( this . element ) ;
2711
+ }
2702
2712
// add space back to packer
2703
2713
this . layout . packer . addSpace ( this . rect ) ;
2704
2714
this . emitEvent ( 'remove' , [ this ] ) ;
@@ -2741,14 +2751,14 @@ return Item;
2741
2751
} ) ) ;
2742
2752
2743
2753
/*!
2744
- * Packery v2.1.1
2754
+ * Packery v2.1.2
2745
2755
* Gapless, draggable grid layouts
2746
2756
*
2747
2757
* Licensed GPLv3 for open source use
2748
2758
* or Packery Commercial License for commercial use
2749
2759
*
2750
2760
* http://packery.metafizzy.co
2751
- * Copyright 2016 Metafizzy
2761
+ * Copyright 2013-2018 Metafizzy
2752
2762
*/
2753
2763
2754
2764
( function ( window , factory ) {
@@ -3304,7 +3314,8 @@ proto.itemDragMove = function( elem, x, y ) {
3304
3314
3305
3315
// throttle
3306
3316
var now = new Date ( ) ;
3307
- if ( this . _itemDragTime && now - this . _itemDragTime < DRAG_THROTTLE_TIME ) {
3317
+ var isThrottled = this . _itemDragTime && now - this . _itemDragTime < DRAG_THROTTLE_TIME ;
3318
+ if ( isThrottled ) {
3308
3319
clearTimeout ( this . dragTimeout ) ;
3309
3320
this . dragTimeout = setTimeout ( onDrag , DRAG_THROTTLE_TIME ) ;
3310
3321
} else {
0 commit comments