Skip to content

Commit

Permalink
πŸ‘·β€β™€οΈ build v3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
desandro committed Apr 13, 2018
1 parent 9d042b1 commit 7ef024f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
58 changes: 34 additions & 24 deletions dist/infinite-scroll.pkgd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Infinite Scroll PACKAGED v3.0.3
* Infinite Scroll PACKAGED v3.0.4
* Automatically add next page
*
* Licensed GPLv3 for open source use
Expand Down Expand Up @@ -321,7 +321,7 @@ return EvEmitter;
}));

/**
* Fizzy UI utils v2.0.5
* Fizzy UI utils v2.0.7
* MIT license
*/

Expand Down Expand Up @@ -376,23 +376,27 @@ utils.modulo = function( num, div ) {

// ----- makeArray ----- //

var arraySlice = Array.prototype.slice;

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

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 ];
};

// ----- removeFrom ----- //
Expand Down Expand Up @@ -471,22 +475,21 @@ utils.filterFindElements = function( elems, selector ) {
// ----- debounceMethod ----- //

utils.debounceMethod = function( _class, methodName, threshold ) {
threshold = threshold || 100;
// original method
var method = _class.prototype[ methodName ];
var timeoutName = methodName + 'Timeout';

_class.prototype[ methodName ] = function() {
var timeout = this[ timeoutName ];
if ( timeout ) {
clearTimeout( timeout );
}
var args = arguments;
clearTimeout( timeout );

var args = arguments;
var _this = this;
this[ timeoutName ] = setTimeout( function() {
method.apply( _this, args );
delete _this[ timeoutName ];
}, threshold || 100 );
}, threshold );
};
};

Expand Down Expand Up @@ -650,8 +653,9 @@ proto.create = function() {
this.pageIndex = 1; // default to first page
this.loadCount = 0;
this.updateGetPath();
// bail if getPath not set
if ( !this.getPath ) {
// bail if getPath not set, or returns falsey #776
var hasPath = this.getPath && this.getPath();
if ( !hasPath ) {
console.error('Disabling InfiniteScroll');
return;
}
Expand Down Expand Up @@ -798,7 +802,7 @@ proto.updateGetPathTemplate = function( optPath ) {
var match = location.href.match( templateRe );
if ( match ) {
this.pageIndex = parseInt( match[1], 10 );
this.log( 'pageIndex', this.pageIndex, 'template string' );
this.log( 'pageIndex', [ this.pageIndex, 'template string' ] );
}
};

Expand Down Expand Up @@ -1078,6 +1082,8 @@ function refreshScripts( fragment ) {
var script = scripts[i];
var freshScript = document.createElement('script');
copyAttributes( script, freshScript );
// copy inner script code. #718, #782
freshScript.innerHTML = script.innerHTML;
script.parentNode.replaceChild( freshScript, script );
}
}
Expand Down Expand Up @@ -1200,7 +1206,7 @@ proto.getPrefillDistance = function() {
};

proto.stopPrefill = function() {
console.log('stopping prefill');
this.log('stopPrefill');
this.off( 'append', this.prefill );
};

Expand Down Expand Up @@ -1462,6 +1468,10 @@ proto.destroyHistory = function() {
// ----- append history ----- //

proto.onAppendHistory = function( response, path, items ) {
// do not proceed if no items. #779
if ( !items || !items.length ) {
return;
}
var firstItem = items[0];
var elemScrollY = this.getElementScrollY( firstItem );
// resolve path
Expand Down Expand Up @@ -1538,7 +1548,7 @@ proto.setHistory = function( title, path ) {
};

// scroll to top to prevent initial scroll-reset after page refresh
// http://stackoverflow.com/a/18633915/182183
// https://stackoverflow.com/a/18633915/182183
proto.onUnload = function() {
var pageIndex = this.scrollPageIndex;
if ( pageIndex === 0 ) {
Expand Down Expand Up @@ -1768,7 +1778,7 @@ return InfiniteScroll;
}));

/*!
* Infinite Scroll v3.0.3
* Infinite Scroll v3.0.4
* Automatically add next page
*
* Licensed GPLv3 for open source use
Expand Down
Loading

0 comments on commit 7ef024f

Please sign in to comment.