1
1
/*!
2
- * Infinite Scroll PACKAGED v3.0.2
2
+ * Infinite Scroll PACKAGED v3.0.3
3
3
* Automatically add next page
4
4
*
5
5
* Licensed GPLv3 for open source use
6
6
* or Infinite Scroll Commercial License for commercial use
7
7
*
8
8
* https://infinite-scroll.com
9
- * Copyright 2017 Metafizzy
9
+ * Copyright 2018 Metafizzy
10
10
*/
11
11
12
12
/**
@@ -234,13 +234,14 @@ proto.emitEvent = function( eventName, args ) {
234
234
if ( ! listeners || ! listeners . length ) {
235
235
return ;
236
236
}
237
- var i = 0 ;
238
- var listener = listeners [ i ] ;
237
+ // copy over to avoid interference if .off() in listener
238
+ listeners = listeners . slice ( 0 ) ;
239
239
args = args || [ ] ;
240
240
// once stuff
241
241
var onceListeners = this . _onceEvents && this . _onceEvents [ eventName ] ;
242
242
243
- while ( listener ) {
243
+ for ( var i = 0 ; i < listeners . length ; i ++ ) {
244
+ var listener = listeners [ i ]
244
245
var isOnce = onceListeners && onceListeners [ listener ] ;
245
246
if ( isOnce ) {
246
247
// remove listener
@@ -251,16 +252,12 @@ proto.emitEvent = function( eventName, args ) {
251
252
}
252
253
// trigger listener
253
254
listener . apply ( this , args ) ;
254
- // get next listener
255
- i += isOnce ? 0 : 1 ;
256
- listener = listeners [ i ] ;
257
255
}
258
256
259
257
return this ;
260
258
} ;
261
259
262
- proto . allOff =
263
- proto . removeAllListeners = function ( ) {
260
+ proto . allOff = function ( ) {
264
261
delete this . _events ;
265
262
delete this . _onceEvents ;
266
263
} ;
@@ -985,7 +982,7 @@ InfiniteScroll.defaults.responseType = 'document';
985
982
InfiniteScroll . create . pageLoad = function ( ) {
986
983
this . canLoad = true ;
987
984
this . on ( 'scrollThreshold' , this . onScrollThresholdLoad ) ;
988
- this . on ( 'append ' , this . checkLastPage ) ;
985
+ this . on ( 'load ' , this . checkLastPage ) ;
989
986
if ( this . options . outlayer ) {
990
987
this . on ( 'append' , this . onAppendOutlayer ) ;
991
988
}
@@ -1771,14 +1768,14 @@ return InfiniteScroll;
1771
1768
} ) ) ;
1772
1769
1773
1770
/*!
1774
- * Infinite Scroll v3.0.2
1771
+ * Infinite Scroll v3.0.3
1775
1772
* Automatically add next page
1776
1773
*
1777
1774
* Licensed GPLv3 for open source use
1778
1775
* or Infinite Scroll Commercial License for commercial use
1779
1776
*
1780
1777
* https://infinite-scroll.com
1781
- * Copyright 2017 Metafizzy
1778
+ * Copyright 2018 Metafizzy
1782
1779
*/
1783
1780
1784
1781
( function ( window , factory ) {
@@ -1811,7 +1808,7 @@ return InfiniteScroll;
1811
1808
} ) ;
1812
1809
1813
1810
/*!
1814
- * imagesLoaded v4.1.3
1811
+ * imagesLoaded v4.1.4
1815
1812
* JavaScript is all like "You images are done yet or what?"
1816
1813
* MIT License
1817
1814
*/
@@ -1863,22 +1860,23 @@ function extend( a, b ) {
1863
1860
return a ;
1864
1861
}
1865
1862
1863
+ var arraySlice = Array . prototype . slice ;
1864
+
1866
1865
// turn element or nodeList into an array
1867
1866
function makeArray ( obj ) {
1868
- var ary = [ ] ;
1869
1867
if ( Array . isArray ( obj ) ) {
1870
1868
// use object if already an array
1871
- ary = obj ;
1872
- } else if ( typeof obj . length == 'number' ) {
1869
+ return obj ;
1870
+ }
1871
+
1872
+ var isArrayLike = typeof obj == 'object' && typeof obj . length == 'number' ;
1873
+ if ( isArrayLike ) {
1873
1874
// convert nodeList to array
1874
- for ( var i = 0 ; i < obj . length ; i ++ ) {
1875
- ary . push ( obj [ i ] ) ;
1876
- }
1877
- } else {
1878
- // array of single index
1879
- ary . push ( obj ) ;
1875
+ return arraySlice . call ( obj ) ;
1880
1876
}
1881
- return ary ;
1877
+
1878
+ // array of single index
1879
+ return [ obj ] ;
1882
1880
}
1883
1881
1884
1882
// -------------------------- imagesLoaded -------------------------- //
@@ -1894,13 +1892,19 @@ function ImagesLoaded( elem, options, onAlways ) {
1894
1892
return new ImagesLoaded ( elem , options , onAlways ) ;
1895
1893
}
1896
1894
// use elem as selector string
1895
+ var queryElem = elem ;
1897
1896
if ( typeof elem == 'string' ) {
1898
- elem = document . querySelectorAll ( elem ) ;
1897
+ queryElem = document . querySelectorAll ( elem ) ;
1898
+ }
1899
+ // bail if bad element
1900
+ if ( ! queryElem ) {
1901
+ console . error ( 'Bad element for imagesLoaded ' + ( queryElem || elem ) ) ;
1902
+ return ;
1899
1903
}
1900
1904
1901
- this . elements = makeArray ( elem ) ;
1905
+ this . elements = makeArray ( queryElem ) ;
1902
1906
this . options = extend ( { } , this . options ) ;
1903
-
1907
+ // shift arguments if no options set
1904
1908
if ( typeof options == 'function' ) {
1905
1909
onAlways = options ;
1906
1910
} else {
@@ -1919,9 +1923,7 @@ function ImagesLoaded( elem, options, onAlways ) {
1919
1923
}
1920
1924
1921
1925
// HACK check async to allow time to bind listeners
1922
- setTimeout ( function ( ) {
1923
- this . check ( ) ;
1924
- } . bind ( this ) ) ;
1926
+ setTimeout ( this . check . bind ( this ) ) ;
1925
1927
}
1926
1928
1927
1929
ImagesLoaded . prototype = Object . create ( EvEmitter . prototype ) ;
@@ -2089,7 +2091,9 @@ LoadingImage.prototype.check = function() {
2089
2091
} ;
2090
2092
2091
2093
LoadingImage . prototype . getIsImageComplete = function ( ) {
2092
- return this . img . complete && this . img . naturalWidth !== undefined ;
2094
+ // check for non-zero, non-undefined naturalWidth
2095
+ // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
2096
+ return this . img . complete && this . img . naturalWidth ;
2093
2097
} ;
2094
2098
2095
2099
LoadingImage . prototype . confirm = function ( isLoaded , message ) {
0 commit comments