Skip to content

Commit

Permalink
πŸ‘· build v3.0.3; ⬆️ update imagesLoaded v4.1.4
Browse files Browse the repository at this point in the history
for #671

πŸ“… 2018
  • Loading branch information
desandro committed Jan 12, 2018
1 parent cc77e1d commit d2b25d9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
66 changes: 35 additions & 31 deletions dist/infinite-scroll.pkgd.js
@@ -1,12 +1,12 @@
/*!
* Infinite Scroll PACKAGED v3.0.2
* Infinite Scroll PACKAGED v3.0.3
* Automatically add next page
*
* Licensed GPLv3 for open source use
* or Infinite Scroll Commercial License for commercial use
*
* https://infinite-scroll.com
* Copyright 2017 Metafizzy
* Copyright 2018 Metafizzy
*/

/**
Expand Down Expand Up @@ -234,13 +234,14 @@ proto.emitEvent = function( eventName, args ) {
if ( !listeners || !listeners.length ) {
return;
}
var i = 0;
var listener = listeners[i];
// copy over to avoid interference if .off() in listener
listeners = listeners.slice(0);
args = args || [];
// once stuff
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];

while ( listener ) {
for ( var i=0; i < listeners.length; i++ ) {
var listener = listeners[i]
var isOnce = onceListeners && onceListeners[ listener ];
if ( isOnce ) {
// remove listener
Expand All @@ -251,16 +252,12 @@ proto.emitEvent = function( eventName, args ) {
}
// trigger listener
listener.apply( this, args );
// get next listener
i += isOnce ? 0 : 1;
listener = listeners[i];
}

return this;
};

proto.allOff =
proto.removeAllListeners = function() {
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
};
Expand Down Expand Up @@ -985,7 +982,7 @@ InfiniteScroll.defaults.responseType = 'document';
InfiniteScroll.create.pageLoad = function() {
this.canLoad = true;
this.on( 'scrollThreshold', this.onScrollThresholdLoad );
this.on( 'append', this.checkLastPage );
this.on( 'load', this.checkLastPage );
if ( this.options.outlayer ) {
this.on( 'append', this.onAppendOutlayer );
}
Expand Down Expand Up @@ -1771,14 +1768,14 @@ return InfiniteScroll;
}));

/*!
* Infinite Scroll v3.0.2
* Infinite Scroll v3.0.3
* Automatically add next page
*
* Licensed GPLv3 for open source use
* or Infinite Scroll Commercial License for commercial use
*
* https://infinite-scroll.com
* Copyright 2017 Metafizzy
* Copyright 2018 Metafizzy
*/

( function( window, factory ) {
Expand Down Expand Up @@ -1811,7 +1808,7 @@ return InfiniteScroll;
});

/*!
* imagesLoaded v4.1.3
* imagesLoaded v4.1.4
* JavaScript is all like "You images are done yet or what?"
* MIT License
*/
Expand Down Expand Up @@ -1863,22 +1860,23 @@ function extend( a, b ) {
return a;
}

var arraySlice = Array.prototype.slice;

// turn element or nodeList into an array
function makeArray( obj ) {
var ary = [];
if ( Array.isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( typeof obj.length == 'number' ) {
return obj;
}

var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
if ( isArrayLike ) {
// convert nodeList to array
for ( var i=0; i < obj.length; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
return arraySlice.call( obj );
}
return ary;

// array of single index
return [ obj ];
}

// -------------------------- imagesLoaded -------------------------- //
Expand All @@ -1894,13 +1892,19 @@ function ImagesLoaded( elem, options, onAlways ) {
return new ImagesLoaded( elem, options, onAlways );
}
// use elem as selector string
var queryElem = elem;
if ( typeof elem == 'string' ) {
elem = document.querySelectorAll( elem );
queryElem = document.querySelectorAll( elem );
}
// bail if bad element
if ( !queryElem ) {
console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
return;
}

this.elements = makeArray( elem );
this.elements = makeArray( queryElem );
this.options = extend( {}, this.options );

// shift arguments if no options set
if ( typeof options == 'function' ) {
onAlways = options;
} else {
Expand All @@ -1919,9 +1923,7 @@ function ImagesLoaded( elem, options, onAlways ) {
}

// HACK check async to allow time to bind listeners
setTimeout( function() {
this.check();
}.bind( this ));
setTimeout( this.check.bind( this ) );
}

ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
Expand Down Expand Up @@ -2089,7 +2091,9 @@ LoadingImage.prototype.check = function() {
};

LoadingImage.prototype.getIsImageComplete = function() {
return this.img.complete && this.img.naturalWidth !== undefined;
// check for non-zero, non-undefined naturalWidth
// fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
return this.img.complete && this.img.naturalWidth;
};

LoadingImage.prototype.confirm = function( isLoaded, message ) {
Expand Down

0 comments on commit d2b25d9

Please sign in to comment.