Socket
Socket
Sign inDemoInstall

@webcreate/infinite-ajax-scroll

Package Overview
Dependencies
6
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0-beta.5 to 3.0.0-beta.6

src/events.js

292

dist/infinite-ajax-scroll.es.js
/**
* Infinite Ajax Scroll v3.0.0-beta.5
* Infinite Ajax Scroll v3.0.0-beta.6
* Turn your existing pagination into infinite scrolling pages with ease

@@ -8,3 +8,3 @@ *

*
* Copyright 2014-2019 Webcreate (Jeroen Fiege)
* Copyright 2014-2020 Webcreate (Jeroen Fiege)
* https://infiniteajaxscroll.com

@@ -26,3 +26,5 @@ */

logger: true,
loadOnScroll: true
loadOnScroll: true,
negativeMargin: 0,
trigger: false,
};

@@ -37,6 +39,25 @@

}
if ($element.length === 0) {
throw new Error(("Element \"" + elementOrSelector + "\" not found for \"" + property + "\""));
}
},
anyElement: function anyElement(elementOrSelector, property) {
var $element = $(elementOrSelector);
if ($element.length === 0) {
throw new Error(("Element \"" + elementOrSelector + "\" not found for \"" + property + "\""));
}
},
warn: function warn(fn) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
try {
fn.apply(void 0, args);
} catch (e) {
if (console && console.warn) {
console.warn(e.message);
}
}
}

@@ -93,5 +114,18 @@ };

return bottom - scrollYBottom;
return Math.trunc(bottom - scrollYBottom);
}
var APPEND = 'append';
var APPENDED = 'appended';
var BINDED = 'binded';
var UNBINDED = 'unbinded';
var HIT = 'hit';
var LOAD = 'load';
var LOADED = 'loaded';
var LAST = 'last';
var NEXT = 'next';
var SCROLLED = 'scrolled';
var RESIZED = 'resized';
var PAGE = 'page';
var defaultLastScroll = {

@@ -119,5 +153,3 @@ y: 0,

this.emitter.emit('scrolled', {scroll: scroll});
this.measure();
this.emitter.emit(SCROLLED, {scroll: scroll});
}

@@ -131,5 +163,3 @@

this.emitter.emit('resized', {scroll: scroll});
this.measure();
this.emitter.emit(RESIZED, {scroll: scroll});
}

@@ -144,2 +174,4 @@

if (!nextEl) {
Assert.warn(Assert.singleElement, ias.options.next, 'options.next');
return;

@@ -159,2 +191,10 @@ }

return !!nextEl;
})
.then(function (hasNextEl) {
// only warn for first page, because at some point it's expected that there is no next element
if (!hasNextEl && pageIndex <= 1 && console && console.warn) {
console.warn(("Element \"" + (ias.options.next) + "\" not found for \"options.next\" on \"" + (data.url) + "\""));
}
return hasNextEl;
});

@@ -170,3 +210,3 @@ });

function expand(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -188,2 +228,3 @@ element: options,

this.options = extend({}, defaults$1, expand(options));
this.originalDisplayStyles = new WeakMap();

@@ -194,20 +235,28 @@ if (!this.options.hide) {

Assert.singleElement(this.options.element, 'pagination.element');
Assert.warn(Assert.anyElement, this.options.element, 'pagination.element');
ias.on('binded', this.hide.bind(this));
ias.on('unbinded', this.restore.bind(this));
ias.on(BINDED, this.hide.bind(this));
ias.on(UNBINDED, this.restore.bind(this));
};
Pagination.prototype.hide = function hide () {
var el = $(this.options.element)[0];
var this$1 = this;
this.originalDisplayStyle = window.getComputedStyle(el).display;
var els = $(this.options.element);
el.style.display = 'none';
els.forEach(function (el) {
this$1.originalDisplayStyles.set(el, window.getComputedStyle(el).display);
el.style.display = 'none';
});
};
Pagination.prototype.restore = function restore () {
var el = $(this.options.element)[0];
var this$1 = this;
el.style.display = this.originalDisplayStyle;
var els = $(this.options.element);
els.forEach(function (el) {
el.style.display = this$1.originalDisplayStyles.get(el) || 'block';
});
};

@@ -227,3 +276,3 @@

function expand$1(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -254,4 +303,4 @@ element: options,

ias.on('binded', this.bind.bind(this));
ias.on('binded', this.hide.bind(this));
ias.on(BINDED, this.bind.bind(this));
ias.on(BINDED, this.hide.bind(this));
};

@@ -262,3 +311,3 @@

ias.on('next', function () {
ias.on(NEXT, function () {
startTime = +new Date();

@@ -269,3 +318,3 @@

ias.on('last', function () {
ias.on(LAST, function () {
self.hide();

@@ -275,3 +324,3 @@ });

// setup delay
ias.on('append', function (event) {
ias.on(APPEND, function (event) {
endTime = +new Date();

@@ -394,6 +443,6 @@ diff = endTime - startTime;

ias.on('binded', this.binded.bind(this));
ias.on('next', this.next.bind(this));
ias.on('scrolled', this.scrolled.bind(this));
ias.on('resized', this.scrolled.bind(this));
ias.on(BINDED, this.binded.bind(this));
ias.on(NEXT, this.next.bind(this));
ias.on(SCROLLED, this.scrolled.bind(this));
ias.on(RESIZED, this.scrolled.bind(this));
};

@@ -418,4 +467,4 @@

var url;
var title;
var url = document.location.toString();
var title = document.title;

@@ -431,5 +480,5 @@ // @todo can be moved inside appended when eventStack is implemented

this.ias.once('loaded', loaded);
this.ias.once(LOADED, loaded);
this.ias.once('appended', function () {
this.ias.once(APPENDED, function () {
this$1.pageBreaks.push({

@@ -445,3 +494,3 @@ pageIndex: nextEvent.pageIndex,

// @todo can be removed when eventStack is implemented
this$1.ias.off('loaded', loaded);
this$1.ias.off(LOADED, loaded);
});

@@ -460,3 +509,3 @@ };

if (pageBreak && pageBreak.pageIndex !== this.currentPageIndex) {
this.ias.emitter.emit('page', pageBreak);
this.ias.emitter.emit(PAGE, pageBreak);

@@ -467,2 +516,119 @@ this.currentPageIndex = pageBreak.pageIndex;

var defaults$3 = {
element: undefined,
when: function (pageIndex) { return true; },
show: function (element) {
element.style.opacity = '1';
},
hide: function (element) {
element.style.opacity = '0';
}
};
function expand$3(options) {
if (typeof options === 'string' || typeof options === 'function' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {
element: options,
};
}
if (typeof options.element === 'function') {
options.element = options.element();
}
// expand array to a function, e.g.:
// [0, 1, 2] -> function(pageIndex) { /* return true when pageIndex in [0, 1, 2] */ }
if (options.when && Array.isArray(options.when)) {
var when = options.when;
options.when = function(pageIndex) {
return when.indexOf(pageIndex) !== -1;
};
}
return options;
}
var Trigger = function Trigger(ias, options) {
var this$1 = this;
// no trigger wanted
if (options === false) {
return;
}
this.ias = ias;
this.options = extend({}, defaults$3, expand$3(options));
if (this.options.element !== undefined) {
Assert.singleElement(this.options.element, 'trigger.element');
}
this.element = $(this.options.element)[0]; // @todo should we really cache this?
this.hideFn = this.options.hide;
this.showFn = this.options.show;
this.voter = this.options.when;
this.showing = undefined;
this.enabled = undefined;
ias.on(BINDED, this.bind.bind(this));
ias.on(UNBINDED, this.unbind.bind(this));
ias.on(HIT, this.hit.bind(this));
ias.on(NEXT, function (e) { return this$1.ias.once(APPENDED, function () { return this$1.update(e.pageIndex); }); });
};
Trigger.prototype.bind = function bind () {
this.hide();
this.update(this.ias.pageIndex);
this.element.addEventListener('click', this.clickHandler.bind(this));
};
Trigger.prototype.unbind = function unbind () {
this.element.removeEventListener('click', this.clickHandler.bind(this));
};
Trigger.prototype.clickHandler = function clickHandler () {
var this$1 = this;
this.hide().then(function () { return this$1.ias.next(); });
};
Trigger.prototype.update = function update (pageIndex) {
this.enabled = this.voter(pageIndex);
if (this.enabled) {
this.ias.disableLoadOnScroll();
} else {
this.ias.enableLoadOnScroll();
}
};
Trigger.prototype.hit = function hit () {
if (!this.enabled) {
return;
}
this.show();
};
Trigger.prototype.show = function show () {
if (this.showing) {
return;
}
this.showing = true;
return Promise.resolve(this.showFn(this.element));
};
Trigger.prototype.hide = function hide () {
if (!this.showing && this.showing !== undefined) {
return;
}
this.showing = false;
return Promise.resolve(this.hideFn(this.element));
};
function appendFn(items, parent, last) {

@@ -488,4 +654,9 @@ var sibling = last ? last.nextSibling : null;

this.emitter = new Emitter();
// @todo might need to call enableLoadOnScroll (or disableLoadOnScroll)
// instead of injecting the value right away
this.loadOnScroll = this.options.loadOnScroll;
this.negativeMargin = Math.abs(this.options.negativeMargin);
this.scrollContainer = this.options.scrollContainer;
if (this.options.scrollContainer !== window) {

@@ -498,3 +669,6 @@ Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');

this.nextHandler = nextHandler;
if (typeof this.options.next === 'function') {
if (this.options.next === false) {
this.nextHandler = function() {};
} else if (typeof this.options.next === 'function') {
this.nextHandler = this.options.next;

@@ -505,7 +679,5 @@ }

this.paused = false;
this.loadOnScroll = this.options.loadOnScroll;
this.pageIndex = this.sentinel() ? 0 : -1;
this.lastDistance = null;
this.on('hit', function () {
this.on(HIT, function () {
if (!this$1.loadOnScroll) {

@@ -518,2 +690,5 @@ return;

this.on(SCROLLED, this.measure);
this.on(RESIZED, this.measure);
// initialize extensions

@@ -524,5 +699,7 @@ this.pagination = new Pagination(this, this.options.pagination);

this.paging = new Paging(this);
this.trigger = new Trigger(this, this.options.trigger);
// @todo review this logic when prefill support is added
this.on('binded', this.measure);
// measure after all plugins are done binding
this.on(BINDED, this.measure);

@@ -548,3 +725,3 @@ if (this.options.bind) {

this.emitter.emit('binded');
this.emitter.emit(BINDED);
};

@@ -562,3 +739,3 @@

this.emitter.emit('unbinded');
this.emitter.emit(UNBINDED);
};

@@ -575,5 +752,5 @@

this.emitter.emit('next', event);
this.emitter.emit(NEXT, event);
Promise.resolve(this.nextHandler(event.pageIndex))
return Promise.resolve(this.nextHandler(event.pageIndex))
.then(function (result) {

@@ -583,3 +760,3 @@ this$1.pageIndex = event.pageIndex;

if (!result) {
this$1.emitter.emit('last');
this$1.emitter.emit(LAST);

@@ -613,3 +790,3 @@ return;

ias.emitter.emit('loaded', {items: items, url: url, xhr: xhr});
ias.emitter.emit(LOADED, {items: items, url: url, xhr: xhr});

@@ -635,3 +812,3 @@ resolve({items: items, url: url, xhr: xhr});

ias.emitter.emit('load', {url: url, xhr: xhr});
ias.emitter.emit(LOAD, {url: url, xhr: xhr});

@@ -656,3 +833,3 @@ xhr.send();

ias.emitter.emit('append', event);
ias.emitter.emit(APPEND, event);

@@ -668,3 +845,3 @@ var executor = function (resolve) {

return (new Promise(executor)).then(function (event) {
ias.emitter.emit('appended', event);
ias.emitter.emit(APPENDED, event);
});

@@ -714,7 +891,8 @@ };

if (distance <= 0 && (this.lastDistance === null || this.lastDistance > 0)) {
this.emitter.emit('hit', {distance: distance});
// apply negative margin
distance -= this.negativeMargin;
if (distance <= 0) {
this.emitter.emit(HIT, {distance: distance});
}
this.lastDistance = distance;
};

@@ -725,3 +903,3 @@

if (event === 'binded' && this.binded) {
if (event === BINDED && this.binded) {
callback.bind(this)();

@@ -738,3 +916,3 @@ }

if (event === 'binded' && this.binded) {
if (event === BINDED && this.binded) {
callback.bind(this)();

@@ -741,0 +919,0 @@ }

/**
* Infinite Ajax Scroll v3.0.0-beta.5
* Infinite Ajax Scroll v3.0.0-beta.6
* Turn your existing pagination into infinite scrolling pages with ease

@@ -8,3 +8,3 @@ *

*
* Copyright 2014-2019 Webcreate (Jeroen Fiege)
* Copyright 2014-2020 Webcreate (Jeroen Fiege)
* https://infiniteajaxscroll.com

@@ -697,3 +697,5 @@ */

logger: true,
loadOnScroll: true
loadOnScroll: true,
negativeMargin: 0,
trigger: false,
};

@@ -708,6 +710,25 @@

}
if ($element.length === 0) {
throw new Error(("Element \"" + elementOrSelector + "\" not found for \"" + property + "\""));
}
},
anyElement: function anyElement(elementOrSelector, property) {
var $element = tealight(elementOrSelector);
if ($element.length === 0) {
throw new Error(("Element \"" + elementOrSelector + "\" not found for \"" + property + "\""));
}
},
warn: function warn(fn) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
try {
fn.apply(void 0, args);
} catch (e) {
if (console && console.warn) {
console.warn(e.message);
}
}
}

@@ -764,5 +785,18 @@ };

return bottom - scrollYBottom;
return Math.trunc(bottom - scrollYBottom);
}
var APPEND = 'append';
var APPENDED = 'appended';
var BINDED = 'binded';
var UNBINDED = 'unbinded';
var HIT = 'hit';
var LOAD = 'load';
var LOADED = 'loaded';
var LAST = 'last';
var NEXT = 'next';
var SCROLLED = 'scrolled';
var RESIZED = 'resized';
var PAGE = 'page';
var defaultLastScroll = {

@@ -790,5 +824,3 @@ y: 0,

this.emitter.emit('scrolled', {scroll: scroll});
this.measure();
this.emitter.emit(SCROLLED, {scroll: scroll});
}

@@ -802,5 +834,3 @@

this.emitter.emit('resized', {scroll: scroll});
this.measure();
this.emitter.emit(RESIZED, {scroll: scroll});
}

@@ -883,2 +913,4 @@

if (!nextEl) {
Assert.warn(Assert.singleElement, ias.options.next, 'options.next');
return;

@@ -898,2 +930,10 @@ }

return !!nextEl;
})
.then(function (hasNextEl) {
// only warn for first page, because at some point it's expected that there is no next element
if (!hasNextEl && pageIndex <= 1 && console && console.warn) {
console.warn(("Element \"" + (ias.options.next) + "\" not found for \"options.next\" on \"" + (data.url) + "\""));
}
return hasNextEl;
});

@@ -909,3 +949,3 @@ });

function expand(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -927,2 +967,3 @@ element: options,

this.options = extend({}, defaults$1, expand(options));
this.originalDisplayStyles = new WeakMap();

@@ -933,20 +974,28 @@ if (!this.options.hide) {

Assert.singleElement(this.options.element, 'pagination.element');
Assert.warn(Assert.anyElement, this.options.element, 'pagination.element');
ias.on('binded', this.hide.bind(this));
ias.on('unbinded', this.restore.bind(this));
ias.on(BINDED, this.hide.bind(this));
ias.on(UNBINDED, this.restore.bind(this));
};
Pagination.prototype.hide = function hide () {
var el = tealight(this.options.element)[0];
var this$1 = this;
this.originalDisplayStyle = window.getComputedStyle(el).display;
var els = tealight(this.options.element);
el.style.display = 'none';
els.forEach(function (el) {
this$1.originalDisplayStyles.set(el, window.getComputedStyle(el).display);
el.style.display = 'none';
});
};
Pagination.prototype.restore = function restore () {
var el = tealight(this.options.element)[0];
var this$1 = this;
el.style.display = this.originalDisplayStyle;
var els = tealight(this.options.element);
els.forEach(function (el) {
el.style.display = this$1.originalDisplayStyles.get(el) || 'block';
});
};

@@ -966,3 +1015,3 @@

function expand$1(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -993,4 +1042,4 @@ element: options,

ias.on('binded', this.bind.bind(this));
ias.on('binded', this.hide.bind(this));
ias.on(BINDED, this.bind.bind(this));
ias.on(BINDED, this.hide.bind(this));
};

@@ -1001,3 +1050,3 @@

ias.on('next', function () {
ias.on(NEXT, function () {
startTime = +new Date();

@@ -1008,3 +1057,3 @@

ias.on('last', function () {
ias.on(LAST, function () {
self.hide();

@@ -1014,3 +1063,3 @@ });

// setup delay
ias.on('append', function (event) {
ias.on(APPEND, function (event) {
endTime = +new Date();

@@ -1133,6 +1182,6 @@ diff = endTime - startTime;

ias.on('binded', this.binded.bind(this));
ias.on('next', this.next.bind(this));
ias.on('scrolled', this.scrolled.bind(this));
ias.on('resized', this.scrolled.bind(this));
ias.on(BINDED, this.binded.bind(this));
ias.on(NEXT, this.next.bind(this));
ias.on(SCROLLED, this.scrolled.bind(this));
ias.on(RESIZED, this.scrolled.bind(this));
};

@@ -1157,4 +1206,4 @@

var url;
var title;
var url = document.location.toString();
var title = document.title;

@@ -1170,5 +1219,5 @@ // @todo can be moved inside appended when eventStack is implemented

this.ias.once('loaded', loaded);
this.ias.once(LOADED, loaded);
this.ias.once('appended', function () {
this.ias.once(APPENDED, function () {
this$1.pageBreaks.push({

@@ -1184,3 +1233,3 @@ pageIndex: nextEvent.pageIndex,

// @todo can be removed when eventStack is implemented
this$1.ias.off('loaded', loaded);
this$1.ias.off(LOADED, loaded);
});

@@ -1199,3 +1248,3 @@ };

if (pageBreak && pageBreak.pageIndex !== this.currentPageIndex) {
this.ias.emitter.emit('page', pageBreak);
this.ias.emitter.emit(PAGE, pageBreak);

@@ -1206,2 +1255,119 @@ this.currentPageIndex = pageBreak.pageIndex;

var defaults$3 = {
element: undefined,
when: function (pageIndex) { return true; },
show: function (element) {
element.style.opacity = '1';
},
hide: function (element) {
element.style.opacity = '0';
}
};
function expand$3(options) {
if (typeof options === 'string' || typeof options === 'function' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {
element: options,
};
}
if (typeof options.element === 'function') {
options.element = options.element();
}
// expand array to a function, e.g.:
// [0, 1, 2] -> function(pageIndex) { /* return true when pageIndex in [0, 1, 2] */ }
if (options.when && Array.isArray(options.when)) {
var when = options.when;
options.when = function(pageIndex) {
return when.indexOf(pageIndex) !== -1;
};
}
return options;
}
var Trigger = function Trigger(ias, options) {
var this$1 = this;
// no trigger wanted
if (options === false) {
return;
}
this.ias = ias;
this.options = extend({}, defaults$3, expand$3(options));
if (this.options.element !== undefined) {
Assert.singleElement(this.options.element, 'trigger.element');
}
this.element = tealight(this.options.element)[0]; // @todo should we really cache this?
this.hideFn = this.options.hide;
this.showFn = this.options.show;
this.voter = this.options.when;
this.showing = undefined;
this.enabled = undefined;
ias.on(BINDED, this.bind.bind(this));
ias.on(UNBINDED, this.unbind.bind(this));
ias.on(HIT, this.hit.bind(this));
ias.on(NEXT, function (e) { return this$1.ias.once(APPENDED, function () { return this$1.update(e.pageIndex); }); });
};
Trigger.prototype.bind = function bind () {
this.hide();
this.update(this.ias.pageIndex);
this.element.addEventListener('click', this.clickHandler.bind(this));
};
Trigger.prototype.unbind = function unbind () {
this.element.removeEventListener('click', this.clickHandler.bind(this));
};
Trigger.prototype.clickHandler = function clickHandler () {
var this$1 = this;
this.hide().then(function () { return this$1.ias.next(); });
};
Trigger.prototype.update = function update (pageIndex) {
this.enabled = this.voter(pageIndex);
if (this.enabled) {
this.ias.disableLoadOnScroll();
} else {
this.ias.enableLoadOnScroll();
}
};
Trigger.prototype.hit = function hit () {
if (!this.enabled) {
return;
}
this.show();
};
Trigger.prototype.show = function show () {
if (this.showing) {
return;
}
this.showing = true;
return Promise.resolve(this.showFn(this.element));
};
Trigger.prototype.hide = function hide () {
if (!this.showing && this.showing !== undefined) {
return;
}
this.showing = false;
return Promise.resolve(this.hideFn(this.element));
};
function appendFn(items, parent, last) {

@@ -1227,4 +1393,9 @@ var sibling = last ? last.nextSibling : null;

this.emitter = new tinyEmitter();
// @todo might need to call enableLoadOnScroll (or disableLoadOnScroll)
// instead of injecting the value right away
this.loadOnScroll = this.options.loadOnScroll;
this.negativeMargin = Math.abs(this.options.negativeMargin);
this.scrollContainer = this.options.scrollContainer;
if (this.options.scrollContainer !== window) {

@@ -1237,3 +1408,6 @@ Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');

this.nextHandler = nextHandler;
if (typeof this.options.next === 'function') {
if (this.options.next === false) {
this.nextHandler = function() {};
} else if (typeof this.options.next === 'function') {
this.nextHandler = this.options.next;

@@ -1244,7 +1418,5 @@ }

this.paused = false;
this.loadOnScroll = this.options.loadOnScroll;
this.pageIndex = this.sentinel() ? 0 : -1;
this.lastDistance = null;
this.on('hit', function () {
this.on(HIT, function () {
if (!this$1.loadOnScroll) {

@@ -1257,2 +1429,5 @@ return;

this.on(SCROLLED, this.measure);
this.on(RESIZED, this.measure);
// initialize extensions

@@ -1263,5 +1438,7 @@ this.pagination = new Pagination(this, this.options.pagination);

this.paging = new Paging(this);
this.trigger = new Trigger(this, this.options.trigger);
// @todo review this logic when prefill support is added
this.on('binded', this.measure);
// measure after all plugins are done binding
this.on(BINDED, this.measure);

@@ -1287,3 +1464,3 @@ if (this.options.bind) {

this.emitter.emit('binded');
this.emitter.emit(BINDED);
};

@@ -1301,3 +1478,3 @@

this.emitter.emit('unbinded');
this.emitter.emit(UNBINDED);
};

@@ -1314,5 +1491,5 @@

this.emitter.emit('next', event);
this.emitter.emit(NEXT, event);
Promise.resolve(this.nextHandler(event.pageIndex))
return Promise.resolve(this.nextHandler(event.pageIndex))
.then(function (result) {

@@ -1322,3 +1499,3 @@ this$1.pageIndex = event.pageIndex;

if (!result) {
this$1.emitter.emit('last');
this$1.emitter.emit(LAST);

@@ -1352,3 +1529,3 @@ return;

ias.emitter.emit('loaded', {items: items, url: url, xhr: xhr});
ias.emitter.emit(LOADED, {items: items, url: url, xhr: xhr});

@@ -1374,3 +1551,3 @@ resolve({items: items, url: url, xhr: xhr});

ias.emitter.emit('load', {url: url, xhr: xhr});
ias.emitter.emit(LOAD, {url: url, xhr: xhr});

@@ -1395,3 +1572,3 @@ xhr.send();

ias.emitter.emit('append', event);
ias.emitter.emit(APPEND, event);

@@ -1407,3 +1584,3 @@ var executor = function (resolve) {

return (new Promise(executor)).then(function (event) {
ias.emitter.emit('appended', event);
ias.emitter.emit(APPENDED, event);
});

@@ -1453,7 +1630,8 @@ };

if (distance <= 0 && (this.lastDistance === null || this.lastDistance > 0)) {
this.emitter.emit('hit', {distance: distance});
// apply negative margin
distance -= this.negativeMargin;
if (distance <= 0) {
this.emitter.emit(HIT, {distance: distance});
}
this.lastDistance = distance;
};

@@ -1464,3 +1642,3 @@

if (event === 'binded' && this.binded) {
if (event === BINDED && this.binded) {
callback.bind(this)();

@@ -1477,3 +1655,3 @@ }

if (event === 'binded' && this.binded) {
if (event === BINDED && this.binded) {
callback.bind(this)();

@@ -1480,0 +1658,0 @@ }

82

dist/infinite-ajax-scroll.min.js

@@ -1,71 +0,11 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).InfiniteAjaxScroll=e()}(this,(function(){"use strict";
/*! @license is-dom-node v1.0.4
Copyright 2018 Fisssion LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/function t(t){return"object"==typeof window.Node?t instanceof window.Node:null!==t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}
/*! @license is-dom-node-list v1.2.1
Copyright 2018 Fisssion LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*! @license Tealight v0.3.6
Copyright 2018 Fisssion LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
function e(e,n){if(void 0===n&&(n=document),e instanceof Array)return e.filter(t);if(t(e))return[e];if(o=Object.prototype.toString.call(i=e),"object"==typeof window.NodeList?i instanceof window.NodeList:null!==i&&"object"==typeof i&&"number"==typeof i.length&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(o)&&(0===i.length||t(i[0])))return Array.prototype.slice.call(e);var i,o;if("string"==typeof e)try{var r=n.querySelectorAll(e);return Array.prototype.slice.call(r)}catch(t){return[]}return[]}var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},l=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var e,o=n.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!r)return!1;for(e in t);return void 0===e||n.call(t,e)},a=function(t,e){o&&"__proto__"===e.name?o(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,e){if("__proto__"===e){if(!n.call(t,e))return;if(r)return r(t,e).value}return t[e]},u=function t(){var e,n,i,o,r,u,d=arguments,p=arguments[0],h=1,f=arguments.length,m=!1;for("boolean"==typeof p&&(m=p,p=arguments[1]||{},h=2),(null==p||"object"!=typeof p&&"function"!=typeof p)&&(p={});f>h;++h)if(null!=(e=d[h]))for(n in e)i=c(p,n),p!==(o=c(e,n))&&(m&&o&&(l(o)||(r=s(o)))?(r?(r=!1,u=i&&s(i)?i:[]):u=i&&l(i)?i:{},a(p,{name:n,newValue:t(m,u,o)})):void 0!==o&&a(p,{name:n,newValue:o}));return p},d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},p="Expected a function",h=NaN,f="[object Symbol]",m=/^\s+|\s+$/g,y=/^[-+]0x[0-9a-f]+$/i,g=/^0b[01]+$/i,v=/^0o[0-7]+$/i,b=parseInt,w="object"==typeof self&&self&&self.Object===Object&&self,x="object"==typeof d&&d&&d.Object===Object&&d||w||Function("return this")(),S=Object.prototype.toString,O=Math.max,j=Math.min,T=function(){return x.Date.now()};function C(t,e,n){var i,o,r,s,l,a,c=0,u=!1,d=!1,h=!0;if("function"!=typeof t)throw new TypeError(p);function f(e){var n=i,r=o;return i=o=void 0,c=e,s=t.apply(r,n)}function m(t){var n=t-a;return void 0===a||n>=e||0>n||d&&t-c>=r}function y(){var t=T();if(m(t))return g(t);l=setTimeout(y,function(t){var n=e-(t-a);return d?j(n,r-(t-c)):n}(t))}function g(t){return l=void 0,h&&i?f(t):(i=o=void 0,s)}function v(){var t=T(),n=m(t);if(i=arguments,o=this,a=t,n){if(void 0===l)return function(t){return c=t,l=setTimeout(y,e),u?f(t):s}(a);if(d)return l=setTimeout(y,e),f(a)}return void 0===l&&(l=setTimeout(y,e)),s}return e=L(e)||0,I(n)&&(u=!!n.leading,r=(d="maxWait"in n)?O(L(n.maxWait)||0,e):r,h="trailing"in n?!!n.trailing:h),v.cancel=function(){void 0!==l&&clearTimeout(l),c=0,i=a=o=l=void 0},v.flush=function(){return void 0===l?s:g(T())},v}function I(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function L(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&S.call(t)==f}(t))return h;if(I(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=I(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(m,"");var n=g.test(t);return n||v.test(t)?b(t.slice(2),n?2:8):y.test(t)?h:+t}var _=function(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new TypeError(p);return I(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),C(t,e,{leading:i,maxWait:e,trailing:o})},E={item:void 0,next:void 0,pagination:void 0,responseType:"document",bind:!0,scrollContainer:window,spinner:!1,logger:!0,loadOnScroll:!0},P=function(t,n){var i=e(t);if(i.length>1)throw Error('Expected single element for "'+n+'"');if(0===i.length)throw Error('Element "'+t+'" not found for "'+n+'"')};function D(t){if(t!==window)return{x:t.scrollLeft,y:t.scrollTop};var e=void 0!==window.pageXOffset,n="CSS1Compat"===(document.compatMode||"");return{x:e?window.pageXOffset:n?document.documentElement.scrollLeft:document.body.scrollLeft,y:e?window.pageYOffset:n?document.documentElement.scrollTop:document.body.scrollTop}}function F(t){var e;if(t!==window)e=t.getBoundingClientRect();else{var n=document.documentElement,i=document.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return e}var H={y:0,x:0,deltaY:0,deltaX:0};function A(t,e){var n=D(t);return n.deltaY=n.y-(e?e.y:n.y),n.deltaX=n.x-(e?e.x:n.x),n}function N(){var t=this._lastScroll=A(this.scrollContainer,this._lastScroll||H);this.emitter.emit("scrolled",{scroll:t}),this.measure()}function R(){var t=this._lastScroll=A(this.scrollContainer,this._lastScroll||H);this.emitter.emit("resized",{scroll:t}),this.measure()}function B(){}B.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;o>i;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,s=i.length;s>r;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}};var M=B;function q(t){var n=this,i=n._lastResponse||document,o=e(n.options.next,i)[0];if(o)return n.load(o.href).then((function(t){i=n._lastResponse=t.xhr.response;var o=e(n.options.next,i)[0];return n.append(t.items).then((function(){return!!o}))}))}M.TinyEmitter=B;var W={element:void 0,hide:!1};var X=function(t,e){this.options=u({},W,function(t){return"string"==typeof t?t={element:t,hide:!0}:"boolean"==typeof t&&(t={element:void 0,hide:t}),t}(e)),this.options.hide&&(P(this.options.element,"pagination.element"),t.on("binded",this.hide.bind(this)),t.on("unbinded",this.restore.bind(this)))};X.prototype.hide=function(){var t=e(this.options.element)[0];this.originalDisplayStyle=window.getComputedStyle(t).display,t.style.display="none"},X.prototype.restore=function(){e(this.options.element)[0].style.display=this.originalDisplayStyle};var z={element:void 0,delay:600,show:function(t){t.style.opacity="1"},hide:function(t){t.style.opacity="0"}};var k=function(t,n){!1!==n&&(this.ias=t,this.options=u({},z,function(t){return"string"==typeof t&&(t={element:t}),t}(n)),void 0!==this.options.element&&P(this.options.element,"spinner.element"),this.element=e(this.options.element)[0],this.hideFn=this.options.hide,this.showFn=this.options.show,t.on("binded",this.bind.bind(this)),t.on("binded",this.hide.bind(this)))};k.prototype.bind=function(){var t,e,n=this,i=this.ias;i.on("next",(function(){t=+new Date,n.show()})),i.on("last",(function(){n.hide()})),i.on("append",(function(i){e=Math.max(0,n.options.delay-(+new Date-t));var o=i.appendFn;i.appendFn=function(t,i,r){return new Promise((function(s){setTimeout((function(){Promise.resolve(n.hide()).then((function(){o(t,i,r),s()}))}),e)}))}}))},k.prototype.show=function(){return Promise.resolve(this.showFn(this.element))},k.prototype.hide=function(){return Promise.resolve(this.hideFn(this.element))};var $={hit:function(){console.log("Hit scroll threshold")},binded:function(){console.log("Binded event handlers")},unbinded:function(){console.log("Unbinded event handlers")},next:function(t){console.log("Next page triggered [pageIndex="+t.pageIndex+"]")},load:function(t){console.log("Start loading "+t.url)},loaded:function(){console.log("Finished loading")},append:function(){console.log("Start appending items")},appended:function(t){console.log("Finished appending "+t.items.length+" item(s)")},last:function(){console.log("No more pages left to load")},page:function(t){console.log("Page changed [pageIndex="+t.pageIndex+"]")}};var V=function(t,e){if(!1!==e){var n=function(t){return!0===t&&(t=$),t}(e);Object.keys(n).forEach((function(e){t.on(e,n[e])}))}};var Y=function(t){this.ias=t,this.pageBreaks=[],this.currentPageIndex=t.pageIndex,this.currentScrollTop=0,t.on("binded",this.binded.bind(this)),t.on("next",this.next.bind(this)),t.on("scrolled",this.scrolled.bind(this)),t.on("resized",this.scrolled.bind(this))};function G(t,e,n){var i=n?n.nextSibling:null,o=document.createDocumentFragment();t.forEach((function(t){o.appendChild(t)})),e.insertBefore(o,i)}Y.prototype.binded=function(){this.ias.sentinel()&&this.pageBreaks.push({pageIndex:this.currentPageIndex,url:""+document.location,title:document.title,sentinel:this.ias.sentinel()})},Y.prototype.next=function(t){var e,n,i=this,o=function(t){e=t.url,t.xhr.response&&(n=t.xhr.response.title)};this.ias.once("loaded",o),this.ias.once("appended",(function(){i.pageBreaks.push({pageIndex:t.pageIndex,url:e,title:n,sentinel:i.ias.sentinel()}),i.update(),i.ias.off("loaded",o)}))},Y.prototype.scrolled=function(t){this.update(t.scroll.y)},Y.prototype.update=function(t){this.currentScrollTop=t||this.currentScrollTop;var e=function(t,e,n){for(var i=e+F(n).height,o=t.length-1;o>=0;o--){if(i>t[o].sentinel.getBoundingClientRect().bottom+e)return t[Math.min(o+1,t.length-1)]}return t[0]}(this.pageBreaks,this.currentScrollTop,this.ias.scrollContainer);e&&e.pageIndex!==this.currentPageIndex&&(this.ias.emitter.emit("page",e),this.currentPageIndex=e.pageIndex)};var U=function(t,n){var i=this;void 0===n&&(n={}),P(t,"container"),this.container=e(t)[0],this.options=u({},E,n),this.emitter=new M,this.scrollContainer=this.options.scrollContainer,this.options.scrollContainer!==window&&(P(this.options.scrollContainer,"options.scrollContainer"),this.scrollContainer=e(this.options.scrollContainer)[0]),this.nextHandler=q,"function"==typeof this.options.next&&(this.nextHandler=this.options.next),this.binded=!1,this.paused=!1,this.loadOnScroll=this.options.loadOnScroll,this.pageIndex=this.sentinel()?0:-1,this.lastDistance=null,this.on("hit",(function(){i.loadOnScroll&&i.next()})),this.pagination=new X(this,this.options.pagination),this.spinner=new k(this,this.options.spinner),this.logger=new V(this,this.options.logger),this.paging=new Y(this),this.on("binded",this.measure),this.options.bind&&this.bind()};return U.prototype.bind=function(){this.binded||(this._scrollListener=_(N,200).bind(this),this._resizeListener=_(R,200).bind(this),this.scrollContainer.addEventListener("scroll",this._scrollListener),this.scrollContainer.addEventListener("resize",this._resizeListener),this.binded=!0,this.emitter.emit("binded"))},U.prototype.unbind=function(){this.binded&&(this.scrollContainer.removeEventListener("resize",this._resizeListener),this.scrollContainer.removeEventListener("scroll",this._scrollListener),this.binded=!1,this.emitter.emit("unbinded"))},U.prototype.next=function(){var t=this;this.pause();var e={pageIndex:this.pageIndex+1};this.emitter.emit("next",e),Promise.resolve(this.nextHandler(e.pageIndex)).then((function(n){t.pageIndex=e.pageIndex,n?t.resume():t.emitter.emit("last")}))},U.prototype.load=function(t){var n=this;return new Promise((function(i,o){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===XMLHttpRequest.DONE)if(200===r.status){var s=r.response;"document"===n.options.responseType&&(s=e(n.options.item,r.response)),n.emitter.emit("loaded",{items:s,url:t,xhr:r}),i({items:s,url:t,xhr:r})}else console.error("Request failed"),o(r)};var s=t+(/\?/.test(t)?"&":"?")+(new Date).getTime();r.open("GET",s,!0),r.responseType=n.options.responseType,r.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.emitter.emit("load",{url:t,xhr:r}),r.send()}))},U.prototype.append=function(t,e){var n=this,i={items:t,parent:e=e||n.container,appendFn:G};n.emitter.emit("append",i);return new Promise((function(o){window.requestAnimationFrame((function(){Promise.resolve(i.appendFn(i.items,i.parent,n.sentinel())).then((function(){o({items:t,parent:e})}))}))})).then((function(t){n.emitter.emit("appended",t)}))},U.prototype.sentinel=function(){var t=e(this.options.item,this.container);return t.length?t[t.length-1]:null},U.prototype.pause=function(){this.paused=!0},U.prototype.resume=function(){this.paused=!1,this.measure()},U.prototype.enableLoadOnScroll=function(){this.loadOnScroll=!0},U.prototype.disableLoadOnScroll=function(){this.loadOnScroll=!1},U.prototype.measure=function(){if(!this.paused){var t,e,n,i,o,r=0,s=this.sentinel();s&&(t=s,n=D(e=this.scrollContainer),i=F(e),o=t.getBoundingClientRect(),r=n.y+o.bottom-i.top-(n.y+i.height)),r>0||null!==this.lastDistance&&0>=this.lastDistance||this.emitter.emit("hit",{distance:r}),this.lastDistance=r}},U.prototype.on=function(t,e){this.emitter.on(t,e,this),"binded"===t&&this.binded&&e.bind(this)()},U.prototype.off=function(t,e){this.emitter.off(t,e,this)},U.prototype.once=function(t,e){this.emitter.once(t,e,this),"binded"===t&&this.binded&&e.bind(this)()},U}));
/**
* Infinite Ajax Scroll v3.0.0-beta.6
* Turn your existing pagination into infinite scrolling pages with ease
*
* Commercial use requires one-time purchase of a commercial license
* https://infiniteajaxscroll.com/docs/license.html
*
* Copyright 2014-2020 Webcreate (Jeroen Fiege)
* https://infiniteajaxscroll.com
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).InfiniteAjaxScroll=e()}(this,(function(){"use strict";function t(t){return"object"==typeof window.Node?t instanceof window.Node:null!==t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}function e(e,n){if(void 0===n&&(n=document),e instanceof Array)return e.filter(t);if(t(e))return[e];if(o=Object.prototype.toString.call(i=e),"object"==typeof window.NodeList?i instanceof window.NodeList:null!==i&&"object"==typeof i&&"number"==typeof i.length&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(o)&&(0===i.length||t(i[0])))return Array.prototype.slice.call(e);var i,o;if("string"==typeof e)try{var r=n.querySelectorAll(e);return Array.prototype.slice.call(r)}catch(t){return[]}return[]}var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},l=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var e,o=n.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&n.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!o&&!r)return!1;for(e in t);return void 0===e||n.call(t,e)},a=function(t,e){o&&"__proto__"===e.name?o(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},c=function(t,e){if("__proto__"===e){if(!n.call(t,e))return;if(r)return r(t,e).value}return t[e]},h=function t(){var e,n,i,o,r,h,u=arguments,d=arguments[0],p=1,f=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},p=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f>p;++p)if(null!=(e=u[p]))for(n in e)i=c(d,n),d!==(o=c(e,n))&&(m&&o&&(l(o)||(r=s(o)))?(r?(r=!1,h=i&&s(i)?i:[]):h=i&&l(i)?i:{},a(d,{name:n,newValue:t(m,h,o)})):void 0!==o&&a(d,{name:n,newValue:o}));return d},u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=/^\s+|\s+$/g,p=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,m=/^0o[0-7]+$/i,g=parseInt,y="object"==typeof self&&self&&self.Object===Object&&self,v="object"==typeof u&&u&&u.Object===Object&&u||y||Function("return this")(),b=Object.prototype.toString,w=Math.max,x=Math.min,E=function(){return v.Date.now()};function O(t,e,n){var i,o,r,s,l,a,c=0,h=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=i,r=o;return i=o=void 0,c=e,s=t.apply(r,n)}function f(t){return c=t,l=setTimeout(g,e),h?p(t):s}function m(t){var n=t-a;return void 0===a||n>=e||0>n||u&&t-c>=r}function g(){var t=E();if(m(t))return y(t);l=setTimeout(g,function(t){var n=e-(t-a);return u?x(n,r-(t-c)):n}(t))}function y(t){return l=void 0,d&&i?p(t):(i=o=void 0,s)}function v(){var t=E(),n=m(t);if(i=arguments,o=this,a=t,n){if(void 0===l)return f(a);if(u)return l=setTimeout(g,e),p(a)}return void 0===l&&(l=setTimeout(g,e)),s}return e=T(e)||0,S(n)&&(h=!!n.leading,r=(u="maxWait"in n)?w(T(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==l&&clearTimeout(l),c=0,i=a=o=l=void 0},v.flush=function(){return void 0===l?s:y(E())},v}function S(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function T(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}(t))return NaN;if(S(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=S(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(d,"");var n=f.test(t);return n||m.test(t)?g(t.slice(2),n?2:8):p.test(t)?NaN:+t}var j=function(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return S(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),O(t,e,{leading:i,maxWait:e,trailing:o})},L={item:void 0,next:void 0,pagination:void 0,responseType:"document",bind:!0,scrollContainer:window,spinner:!1,logger:!0,loadOnScroll:!0,negativeMargin:0,trigger:!1},_=function(t,n){var i=e(t);if(i.length>1)throw Error('Expected single element for "'+n+'"');if(0===i.length)throw Error('Element "'+t+'" not found for "'+n+'"')},C=function(t,n){if(0===e(t).length)throw Error('Element "'+t+'" not found for "'+n+'"')},I=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];try{t.apply(void 0,e)}catch(t){console&&console.warn&&console.warn(t.message)}};function N(t){if(t!==window)return{x:t.scrollLeft,y:t.scrollTop};var e=void 0!==window.pageXOffset,n="CSS1Compat"===(document.compatMode||"");return{x:e?window.pageXOffset:n?document.documentElement.scrollLeft:document.body.scrollLeft,y:e?window.pageYOffset:n?document.documentElement.scrollTop:document.body.scrollTop}}function M(t){var e;if(t!==window)e=t.getBoundingClientRect();else{var n=document.documentElement,i=document.body;e={top:0,left:0,right:n.clientWidth||i.clientWidth,width:n.clientWidth||i.clientWidth,bottom:n.clientHeight||i.clientHeight,height:n.clientHeight||i.clientHeight}}return e}var P="binded",F={y:0,x:0,deltaY:0,deltaX:0};function H(t,e){var n=N(t);return n.deltaY=n.y-(e?e.y:n.y),n.deltaX=n.x-(e?e.x:n.x),n}function A(){var t=this._lastScroll=H(this.scrollContainer,this._lastScroll||F);this.emitter.emit("scrolled",{scroll:t})}function D(){var t=this._lastScroll=H(this.scrollContainer,this._lastScroll||F);this.emitter.emit("resized",{scroll:t})}function k(){}k.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;o>i;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,s=i.length;s>r;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}};var R=k;function B(t){var n=this,i=n._lastResponse||document,o=e(n.options.next,i)[0];if(o)return n.load(o.href).then((function(o){i=n._lastResponse=o.xhr.response;var r=e(n.options.next,i)[0];return n.append(o.items).then((function(){return!!r})).then((function(e){return!e&&1>=t&&console&&console.warn&&console.warn('Element "'+n.options.next+'" not found for "options.next" on "'+o.url+'"'),e}))}));I(_,n.options.next,"options.next")}R.TinyEmitter=k;var W={element:void 0,hide:!1};var q=function(t,e){this.options=h({},W,function(t){return"string"==typeof t||"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE?t={element:t,hide:!0}:"boolean"==typeof t&&(t={element:void 0,hide:t}),t}(e)),this.originalDisplayStyles=new WeakMap,this.options.hide&&(I(C,this.options.element,"pagination.element"),t.on(P,this.hide.bind(this)),t.on("unbinded",this.restore.bind(this)))};q.prototype.hide=function(){var t=this;e(this.options.element).forEach((function(e){t.originalDisplayStyles.set(e,window.getComputedStyle(e).display),e.style.display="none"}))},q.prototype.restore=function(){var t=this;e(this.options.element).forEach((function(e){e.style.display=t.originalDisplayStyles.get(e)||"block"}))};var z={element:void 0,delay:600,show:function(t){t.style.opacity="1"},hide:function(t){t.style.opacity="0"}};var X=function(t,n){!1!==n&&(this.ias=t,this.options=h({},z,function(t){return("string"==typeof t||"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE)&&(t={element:t}),t}(n)),void 0!==this.options.element&&_(this.options.element,"spinner.element"),this.element=e(this.options.element)[0],this.hideFn=this.options.hide,this.showFn=this.options.show,t.on(P,this.bind.bind(this)),t.on(P,this.hide.bind(this)))};X.prototype.bind=function(){var t,e,n=this,i=this.ias;i.on("next",(function(){t=+new Date,n.show()})),i.on("last",(function(){n.hide()})),i.on("append",(function(i){e=Math.max(0,n.options.delay-(+new Date-t));var o=i.appendFn;i.appendFn=function(t,i,r){return new Promise((function(s){setTimeout((function(){Promise.resolve(n.hide()).then((function(){o(t,i,r),s()}))}),e)}))}}))},X.prototype.show=function(){return Promise.resolve(this.showFn(this.element))},X.prototype.hide=function(){return Promise.resolve(this.hideFn(this.element))};var $={hit:function(){console.log("Hit scroll threshold")},binded:function(){console.log("Binded event handlers")},unbinded:function(){console.log("Unbinded event handlers")},next:function(t){console.log("Next page triggered [pageIndex="+t.pageIndex+"]")},load:function(t){console.log("Start loading "+t.url)},loaded:function(){console.log("Finished loading")},append:function(){console.log("Start appending items")},appended:function(t){console.log("Finished appending "+t.items.length+" item(s)")},last:function(){console.log("No more pages left to load")},page:function(t){console.log("Page changed [pageIndex="+t.pageIndex+"]")}};var V=function(t,e){if(!1!==e){var n=function(t){return!0===t&&(t=$),t}(e);Object.keys(n).forEach((function(e){t.on(e,n[e])}))}};var Y=function(t){this.ias=t,this.pageBreaks=[],this.currentPageIndex=t.pageIndex,this.currentScrollTop=0,t.on(P,this.binded.bind(this)),t.on("next",this.next.bind(this)),t.on("scrolled",this.scrolled.bind(this)),t.on("resized",this.scrolled.bind(this))};Y.prototype.binded=function(){this.ias.sentinel()&&this.pageBreaks.push({pageIndex:this.currentPageIndex,url:""+document.location,title:document.title,sentinel:this.ias.sentinel()})},Y.prototype.next=function(t){var e=this,n=""+document.location,i=document.title,o=function(t){n=t.url,t.xhr.response&&(i=t.xhr.response.title)};this.ias.once("loaded",o),this.ias.once("appended",(function(){e.pageBreaks.push({pageIndex:t.pageIndex,url:n,title:i,sentinel:e.ias.sentinel()}),e.update(),e.ias.off("loaded",o)}))},Y.prototype.scrolled=function(t){this.update(t.scroll.y)},Y.prototype.update=function(t){this.currentScrollTop=t||this.currentScrollTop;var e=function(t,e,n){for(var i=e+M(n).height,o=t.length-1;o>=0;o--){if(i>t[o].sentinel.getBoundingClientRect().bottom+e)return t[Math.min(o+1,t.length-1)]}return t[0]}(this.pageBreaks,this.currentScrollTop,this.ias.scrollContainer);e&&e.pageIndex!==this.currentPageIndex&&(this.ias.emitter.emit("page",e),this.currentPageIndex=e.pageIndex)};var G={element:void 0,when:function(t){return!0},show:function(t){t.style.opacity="1"},hide:function(t){t.style.opacity="0"}};var U=function(t,n){var i=this;!1!==n&&(this.ias=t,this.options=h({},G,function(t){if(("string"==typeof t||"function"==typeof t||"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE)&&(t={element:t}),"function"==typeof t.element&&(t.element=t.element()),t.when&&Array.isArray(t.when)){var e=t.when;t.when=function(t){return-1!==e.indexOf(t)}}return t}(n)),void 0!==this.options.element&&_(this.options.element,"trigger.element"),this.element=e(this.options.element)[0],this.hideFn=this.options.hide,this.showFn=this.options.show,this.voter=this.options.when,this.showing=void 0,this.enabled=void 0,t.on(P,this.bind.bind(this)),t.on("unbinded",this.unbind.bind(this)),t.on("hit",this.hit.bind(this)),t.on("next",(function(t){return i.ias.once("appended",(function(){return i.update(t.pageIndex)}))})))};function J(t,e,n){var i=n?n.nextSibling:null,o=document.createDocumentFragment();t.forEach((function(t){o.appendChild(t)})),e.insertBefore(o,i)}U.prototype.bind=function(){this.hide(),this.update(this.ias.pageIndex),this.element.addEventListener("click",this.clickHandler.bind(this))},U.prototype.unbind=function(){this.element.removeEventListener("click",this.clickHandler.bind(this))},U.prototype.clickHandler=function(){var t=this;this.hide().then((function(){return t.ias.next()}))},U.prototype.update=function(t){this.enabled=this.voter(t),this.enabled?this.ias.disableLoadOnScroll():this.ias.enableLoadOnScroll()},U.prototype.hit=function(){this.enabled&&this.show()},U.prototype.show=function(){if(!this.showing)return this.showing=!0,Promise.resolve(this.showFn(this.element))},U.prototype.hide=function(){if(this.showing||void 0===this.showing)return this.showing=!1,Promise.resolve(this.hideFn(this.element))};var K=function(t,n){var i=this;void 0===n&&(n={}),_(t,"container"),this.container=e(t)[0],this.options=h({},L,n),this.emitter=new R,this.loadOnScroll=this.options.loadOnScroll,this.negativeMargin=Math.abs(this.options.negativeMargin),this.scrollContainer=this.options.scrollContainer,this.options.scrollContainer!==window&&(_(this.options.scrollContainer,"options.scrollContainer"),this.scrollContainer=e(this.options.scrollContainer)[0]),this.nextHandler=B,!1===this.options.next?this.nextHandler=function(){}:"function"==typeof this.options.next&&(this.nextHandler=this.options.next),this.binded=!1,this.paused=!1,this.pageIndex=this.sentinel()?0:-1,this.on("hit",(function(){i.loadOnScroll&&i.next()})),this.on("scrolled",this.measure),this.on("resized",this.measure),this.pagination=new q(this,this.options.pagination),this.spinner=new X(this,this.options.spinner),this.logger=new V(this,this.options.logger),this.paging=new Y(this),this.trigger=new U(this,this.options.trigger),this.on(P,this.measure),this.options.bind&&this.bind()};return K.prototype.bind=function(){this.binded||(this._scrollListener=j(A,200).bind(this),this._resizeListener=j(D,200).bind(this),this.scrollContainer.addEventListener("scroll",this._scrollListener),this.scrollContainer.addEventListener("resize",this._resizeListener),this.binded=!0,this.emitter.emit(P))},K.prototype.unbind=function(){this.binded&&(this.scrollContainer.removeEventListener("resize",this._resizeListener),this.scrollContainer.removeEventListener("scroll",this._scrollListener),this.binded=!1,this.emitter.emit("unbinded"))},K.prototype.next=function(){var t=this;this.pause();var e={pageIndex:this.pageIndex+1};return this.emitter.emit("next",e),Promise.resolve(this.nextHandler(e.pageIndex)).then((function(n){t.pageIndex=e.pageIndex,n?t.resume():t.emitter.emit("last")}))},K.prototype.load=function(t){var n=this;return new Promise((function(i,o){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===XMLHttpRequest.DONE)if(200===r.status){var s=r.response;"document"===n.options.responseType&&(s=e(n.options.item,r.response)),n.emitter.emit("loaded",{items:s,url:t,xhr:r}),i({items:s,url:t,xhr:r})}else console.error("Request failed"),o(r)};var s=t+(/\?/.test(t)?"&":"?")+(new Date).getTime();r.open("GET",s,!0),r.responseType=n.options.responseType,r.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.emitter.emit("load",{url:t,xhr:r}),r.send()}))},K.prototype.append=function(t,e){var n=this,i={items:t,parent:e=e||n.container,appendFn:J};n.emitter.emit("append",i);return new Promise((function(o){window.requestAnimationFrame((function(){Promise.resolve(i.appendFn(i.items,i.parent,n.sentinel())).then((function(){o({items:t,parent:e})}))}))})).then((function(t){n.emitter.emit("appended",t)}))},K.prototype.sentinel=function(){var t=e(this.options.item,this.container);return t.length?t[t.length-1]:null},K.prototype.pause=function(){this.paused=!0},K.prototype.resume=function(){this.paused=!1,this.measure()},K.prototype.enableLoadOnScroll=function(){this.loadOnScroll=!0},K.prototype.disableLoadOnScroll=function(){this.loadOnScroll=!1},K.prototype.measure=function(){if(!this.paused){var t,e,n,i,o,r=0,s=this.sentinel();s&&(t=s,n=N(e=this.scrollContainer),i=M(e),o=t.getBoundingClientRect(),r=Math.trunc(n.y+o.bottom-i.top-(n.y+i.height))),(r-=this.negativeMargin)>0||this.emitter.emit("hit",{distance:r})}},K.prototype.on=function(t,e){this.emitter.on(t,e,this),t===P&&this.binded&&e.bind(this)()},K.prototype.off=function(t,e){this.emitter.off(t,e,this)},K.prototype.once=function(t,e){this.emitter.once(t,e,this),t===P&&this.binded&&e.bind(this)()},K}));
{
"name": "@webcreate/infinite-ajax-scroll",
"version": "3.0.0-beta.5",
"version": "3.0.0-beta.6",
"title": "Infinite Ajax Scroll",

@@ -53,3 +53,3 @@ "description": "Turn your existing pagination into infinite scrolling pages with ease",

"devDependencies": {
"cypress": "^3.3.2",
"cypress": "^4.0.0",
"eslint": "^6.0.1",

@@ -56,0 +56,0 @@ "eslint-plugin-cypress": "^2.2.1",

@@ -9,4 +9,2 @@ <p align="center">

**Note: You're viewing the 3.x branch which is in development. See the [2.x](https://github.com/webcreate/infinite-ajax-scroll/tree/2.x) branch for the latest stable version.**
Turn your existing pagination into infinite scrolling pages with ease.

@@ -20,3 +18,3 @@

[![Build Status](https://travis-ci.org/webcreate/infinite-ajax-scroll.svg?branch=3.x)](https://travis-ci.org/webcreate/infinite-ajax-scroll)
[![Build Status](https://travis-ci.org/webcreate/infinite-ajax-scroll.svg?branch=3.x)](https://travis-ci.org/webcreate/infinite-ajax-scroll) [![npm](https://img.shields.io/npm/v/@webcreate/infinite-ajax-scroll)](https://www.npmjs.com/package/@webcreate/infinite-ajax-scroll)

@@ -23,0 +21,0 @@ ## Installation

@@ -10,7 +10,23 @@ import $ from 'tealight';

}
if ($element.length === 0) {
throw new Error(`Element "${elementOrSelector}" not found for "${property}"`);
}
},
anyElement(elementOrSelector, property) {
const $element = $(elementOrSelector);
if ($element.length === 0) {
throw new Error(`Element "${elementOrSelector}" not found for "${property}"`);
}
},
warn(fn, ...args) {
try {
fn(...args)
} catch (e) {
if (console && console.warn) {
console.warn(e.message)
}
}
}
}

@@ -10,3 +10,5 @@ export default {

logger: true,
loadOnScroll: true
loadOnScroll: true,
negativeMargin: 0,
trigger: false,
};

@@ -50,3 +50,3 @@

return bottom - scrollYBottom;
return Math.trunc(bottom - scrollYBottom);
}
import {getScrollPosition} from './dimensions';
import * as Events from './events'

@@ -25,5 +26,3 @@ const defaultLastScroll = {

this.emitter.emit('scrolled', {scroll});
this.measure();
this.emitter.emit(Events.SCROLLED, {scroll});
}

@@ -37,5 +36,3 @@

this.emitter.emit('resized', {scroll});
this.measure();
this.emitter.emit(Events.RESIZED, {scroll});
}

@@ -14,3 +14,5 @@ import $ from 'tealight';

import Paging from './paging';
import Trigger from './trigger';
import {appendFn} from './append';
import * as Events from './events';

@@ -24,4 +26,9 @@ export default class InfiniteAjaxScroll {

this.emitter = new Emitter();
// @todo might need to call enableLoadOnScroll (or disableLoadOnScroll)
// instead of injecting the value right away
this.loadOnScroll = this.options.loadOnScroll;
this.negativeMargin = Math.abs(this.options.negativeMargin);
this.scrollContainer = this.options.scrollContainer;
if (this.options.scrollContainer !== window) {

@@ -34,3 +41,6 @@ Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');

this.nextHandler = nextHandler;
if (typeof this.options.next === 'function') {
if (this.options.next === false) {
this.nextHandler = function() {}
} else if (typeof this.options.next === 'function') {
this.nextHandler = this.options.next;

@@ -41,7 +51,5 @@ }

this.paused = false;
this.loadOnScroll = this.options.loadOnScroll;
this.pageIndex = this.sentinel() ? 0 : -1;
this.lastDistance = null;
this.on('hit', () => {
this.on(Events.HIT, () => {
if (!this.loadOnScroll) {

@@ -54,2 +62,5 @@ return;

this.on(Events.SCROLLED, this.measure);
this.on(Events.RESIZED, this.measure);
// initialize extensions

@@ -60,5 +71,7 @@ this.pagination = new Pagination(this, this.options.pagination);

this.paging = new Paging(this);
this.trigger = new Trigger(this, this.options.trigger);
// @todo review this logic when prefill support is added
this.on('binded', this.measure);
// measure after all plugins are done binding
this.on(Events.BINDED, this.measure);

@@ -84,3 +97,3 @@ if (this.options.bind) {

this.emitter.emit('binded');
this.emitter.emit(Events.BINDED);
}

@@ -98,3 +111,3 @@

this.emitter.emit('unbinded');
this.emitter.emit(Events.UNBINDED);
}

@@ -109,5 +122,5 @@

this.emitter.emit('next', event);
this.emitter.emit(Events.NEXT, event);
Promise.resolve(this.nextHandler(event.pageIndex))
return Promise.resolve(this.nextHandler(event.pageIndex))
.then((result) => {

@@ -117,3 +130,3 @@ this.pageIndex = event.pageIndex;

if (!result) {
this.emitter.emit('last');
this.emitter.emit(Events.LAST);

@@ -147,3 +160,3 @@ return;

ias.emitter.emit('loaded', {items, url, xhr});
ias.emitter.emit(Events.LOADED, {items, url, xhr});

@@ -169,3 +182,3 @@ resolve({items, url, xhr});

ias.emitter.emit('load', {url, xhr});
ias.emitter.emit(Events.LOAD, {url, xhr});

@@ -190,3 +203,3 @@ xhr.send();

ias.emitter.emit('append', event);
ias.emitter.emit(Events.APPEND, event);

@@ -202,3 +215,3 @@ let executor = (resolve) => {

return (new Promise(executor)).then((event) => {
ias.emitter.emit('appended', event);
ias.emitter.emit(Events.APPENDED, event);
});

@@ -248,7 +261,8 @@ }

if (distance <= 0 && (this.lastDistance === null || this.lastDistance > 0)) {
this.emitter.emit('hit', {distance});
// apply negative margin
distance -= this.negativeMargin;
if (distance <= 0) {
this.emitter.emit(Events.HIT, {distance});
}
this.lastDistance = distance;
}

@@ -259,3 +273,3 @@

if (event === 'binded' && this.binded) {
if (event === Events.BINDED && this.binded) {
callback.bind(this)();

@@ -272,3 +286,3 @@ }

if (event === 'binded' && this.binded) {
if (event === Events.BINDED && this.binded) {
callback.bind(this)();

@@ -275,0 +289,0 @@ }

import $ from 'tealight';
import Assert from './assert';

@@ -10,2 +11,4 @@ export function nextHandler(pageIndex) {

if (!nextEl) {
Assert.warn(Assert.singleElement, ias.options.next, 'options.next');
return;

@@ -25,4 +28,12 @@ }

return !!nextEl;
})
.then((hasNextEl) => {
// only warn for first page, because at some point it's expected that there is no next element
if (!hasNextEl && pageIndex <= 1 && console && console.warn) {
console.warn(`Element "${ias.options.next}" not found for "options.next" on "${data.url}"`)
}
return hasNextEl;
});
});
}
import $ from 'tealight';
import extend from 'extend';
import Assert from "./assert";
import * as Events from './events';

@@ -11,3 +12,3 @@ const defaults = {

function expand(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -30,2 +31,3 @@ element: options,

this.options = extend({}, defaults, expand(options));
this.originalDisplayStyles = new WeakMap();

@@ -36,21 +38,25 @@ if (!this.options.hide) {

Assert.singleElement(this.options.element, 'pagination.element');
Assert.warn(Assert.anyElement, this.options.element, 'pagination.element');
ias.on('binded', this.hide.bind(this));
ias.on('unbinded', this.restore.bind(this));
ias.on(Events.BINDED, this.hide.bind(this));
ias.on(Events.UNBINDED, this.restore.bind(this));
}
hide() {
let el = $(this.options.element)[0];
let els = $(this.options.element);
this.originalDisplayStyle = window.getComputedStyle(el).display;
els.forEach((el) => {
this.originalDisplayStyles.set(el, window.getComputedStyle(el).display);
el.style.display = 'none';
el.style.display = 'none';
});
}
restore() {
let el = $(this.options.element)[0];
let els = $(this.options.element);
el.style.display = this.originalDisplayStyle;
els.forEach((el) => {
el.style.display = this.originalDisplayStyles.get(el) || 'block';
});
}
}
import {getRootRect} from "./dimensions";
import * as Events from './events';

@@ -27,6 +28,6 @@ function getPageBreak(pageBreaks, scrollTop, scrollContainer) {

ias.on('binded', this.binded.bind(this));
ias.on('next', this.next.bind(this));
ias.on('scrolled', this.scrolled.bind(this));
ias.on('resized', this.scrolled.bind(this));
ias.on(Events.BINDED, this.binded.bind(this));
ias.on(Events.NEXT, this.next.bind(this));
ias.on(Events.SCROLLED, this.scrolled.bind(this));
ias.on(Events.RESIZED, this.scrolled.bind(this));
}

@@ -49,4 +50,4 @@

next(nextEvent) {
let url;
let title;
let url = document.location.toString();
let title = document.title;

@@ -62,5 +63,5 @@ // @todo can be moved inside appended when eventStack is implemented

this.ias.once('loaded', loaded);
this.ias.once(Events.LOADED, loaded);
this.ias.once('appended', () => {
this.ias.once(Events.APPENDED, () => {
this.pageBreaks.push({

@@ -76,3 +77,3 @@ pageIndex: nextEvent.pageIndex,

// @todo can be removed when eventStack is implemented
this.ias.off('loaded', loaded);
this.ias.off(Events.LOADED, loaded);
});

@@ -91,3 +92,3 @@ }

if (pageBreak && pageBreak.pageIndex !== this.currentPageIndex) {
this.ias.emitter.emit('page', pageBreak);
this.ias.emitter.emit(Events.PAGE, pageBreak);

@@ -94,0 +95,0 @@ this.currentPageIndex = pageBreak.pageIndex;

import $ from 'tealight';
import extend from 'extend';
import Assert from "./assert";
import * as Events from './events';

@@ -17,3 +18,3 @@ const defaults = {

function expand(options) {
if (typeof options === 'string') {
if (typeof options === 'string' || (typeof options === 'object' && options.nodeType === Node.ELEMENT_NODE)) {
options = {

@@ -45,4 +46,4 @@ element: options,

ias.on('binded', this.bind.bind(this));
ias.on('binded', this.hide.bind(this));
ias.on(Events.BINDED, this.bind.bind(this));
ias.on(Events.BINDED, this.hide.bind(this));
}

@@ -53,3 +54,3 @@

ias.on('next', () => {
ias.on(Events.NEXT, () => {
startTime = +new Date();

@@ -60,3 +61,3 @@

ias.on('last', () => {
ias.on(Events.LAST, () => {
self.hide();

@@ -66,3 +67,3 @@ });

// setup delay
ias.on('append', (event) => {
ias.on(Events.APPEND, (event) => {
endTime = +new Date();

@@ -69,0 +70,0 @@ diff = endTime - startTime;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc