fn_b/node_modules/.vite/deps/infinite-scroll.js
2026-02-12 13:55:43 +08:00

1039 lines
35 KiB
JavaScript
Executable File

import {
__commonJS
} from "./chunk-HKJ2B2AA.js";
// node_modules/ev-emitter/ev-emitter.js
var require_ev_emitter = __commonJS({
"node_modules/ev-emitter/ev-emitter.js"(exports, module) {
(function(global, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory();
} else {
global.EvEmitter = factory();
}
})(typeof window != "undefined" ? window : exports, function() {
function EvEmitter() {
}
let proto = EvEmitter.prototype;
proto.on = function(eventName, listener) {
if (!eventName || !listener) return this;
let events = this._events = this._events || {};
let listeners = events[eventName] = events[eventName] || [];
if (!listeners.includes(listener)) {
listeners.push(listener);
}
return this;
};
proto.once = function(eventName, listener) {
if (!eventName || !listener) return this;
this.on(eventName, listener);
let onceEvents = this._onceEvents = this._onceEvents || {};
let onceListeners = onceEvents[eventName] = onceEvents[eventName] || {};
onceListeners[listener] = true;
return this;
};
proto.off = function(eventName, listener) {
let listeners = this._events && this._events[eventName];
if (!listeners || !listeners.length) return this;
let index = listeners.indexOf(listener);
if (index != -1) {
listeners.splice(index, 1);
}
return this;
};
proto.emitEvent = function(eventName, args) {
let listeners = this._events && this._events[eventName];
if (!listeners || !listeners.length) return this;
listeners = listeners.slice(0);
args = args || [];
let onceListeners = this._onceEvents && this._onceEvents[eventName];
for (let listener of listeners) {
let isOnce = onceListeners && onceListeners[listener];
if (isOnce) {
this.off(eventName, listener);
delete onceListeners[listener];
}
listener.apply(this, args);
}
return this;
};
proto.allOff = function() {
delete this._events;
delete this._onceEvents;
return this;
};
return EvEmitter;
});
}
});
// node_modules/fizzy-ui-utils/utils.js
var require_utils = __commonJS({
"node_modules/fizzy-ui-utils/utils.js"(exports, module) {
(function(global, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(global);
} else {
global.fizzyUIUtils = factory(global);
}
})(exports, function factory(global) {
let utils = {};
utils.extend = function(a, b) {
return Object.assign(a, b);
};
utils.modulo = function(num, div) {
return (num % div + div) % div;
};
utils.makeArray = function(obj) {
if (Array.isArray(obj)) return obj;
if (obj === null || obj === void 0) return [];
let isArrayLike = typeof obj == "object" && typeof obj.length == "number";
if (isArrayLike) return [...obj];
return [obj];
};
utils.removeFrom = function(ary, obj) {
let index = ary.indexOf(obj);
if (index != -1) {
ary.splice(index, 1);
}
};
utils.getParent = function(elem, selector) {
while (elem.parentNode && elem != document.body) {
elem = elem.parentNode;
if (elem.matches(selector)) return elem;
}
};
utils.getQueryElement = function(elem) {
if (typeof elem == "string") {
return document.querySelector(elem);
}
return elem;
};
utils.handleEvent = function(event) {
let method = "on" + event.type;
if (this[method]) {
this[method](event);
}
};
utils.filterFindElements = function(elems, selector) {
elems = utils.makeArray(elems);
return elems.filter((elem) => elem instanceof HTMLElement).reduce((ffElems, elem) => {
if (!selector) {
ffElems.push(elem);
return ffElems;
}
if (elem.matches(selector)) {
ffElems.push(elem);
}
let childElems = elem.querySelectorAll(selector);
ffElems = ffElems.concat(...childElems);
return ffElems;
}, []);
};
utils.debounceMethod = function(_class, methodName, threshold) {
threshold = threshold || 100;
let method = _class.prototype[methodName];
let timeoutName = methodName + "Timeout";
_class.prototype[methodName] = function() {
clearTimeout(this[timeoutName]);
let args = arguments;
this[timeoutName] = setTimeout(() => {
method.apply(this, args);
delete this[timeoutName];
}, threshold);
};
};
utils.docReady = function(onDocReady) {
let readyState = document.readyState;
if (readyState == "complete" || readyState == "interactive") {
setTimeout(onDocReady);
} else {
document.addEventListener("DOMContentLoaded", onDocReady);
}
};
utils.toDashed = function(str) {
return str.replace(/(.)([A-Z])/g, function(match, $1, $2) {
return $1 + "-" + $2;
}).toLowerCase();
};
let console2 = global.console;
utils.htmlInit = function(WidgetClass, namespace) {
utils.docReady(function() {
let dashedNamespace = utils.toDashed(namespace);
let dataAttr = "data-" + dashedNamespace;
let dataAttrElems = document.querySelectorAll(`[${dataAttr}]`);
let jQuery = global.jQuery;
[...dataAttrElems].forEach((elem) => {
let attr = elem.getAttribute(dataAttr);
let options;
try {
options = attr && JSON.parse(attr);
} catch (error) {
if (console2) {
console2.error(`Error parsing ${dataAttr} on ${elem.className}: ${error}`);
}
return;
}
let instance = new WidgetClass(elem, options);
if (jQuery) {
jQuery.data(elem, namespace, instance);
}
});
});
};
return utils;
});
}
});
// node_modules/infinite-scroll/js/core.js
var require_core = __commonJS({
"node_modules/infinite-scroll/js/core.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_ev_emitter(),
require_utils()
);
} else {
window2.InfiniteScroll = factory(
window2,
window2.EvEmitter,
window2.fizzyUIUtils
);
}
})(window, function factory(window2, EvEmitter, utils) {
let jQuery = window2.jQuery;
let instances = {};
function InfiniteScroll(element, options) {
let queryElem = utils.getQueryElement(element);
if (!queryElem) {
console.error("Bad element for InfiniteScroll: " + (queryElem || element));
return;
}
element = queryElem;
if (element.infiniteScrollGUID) {
let instance = instances[element.infiniteScrollGUID];
instance.option(options);
return instance;
}
this.element = element;
this.options = { ...InfiniteScroll.defaults };
this.option(options);
if (jQuery) {
this.$element = jQuery(this.element);
}
this.create();
}
InfiniteScroll.defaults = {
// path: null,
// hideNav: null,
// debug: false,
};
InfiniteScroll.create = {};
InfiniteScroll.destroy = {};
let proto = InfiniteScroll.prototype;
Object.assign(proto, EvEmitter.prototype);
let GUID = 0;
proto.create = function() {
let id = this.guid = ++GUID;
this.element.infiniteScrollGUID = id;
instances[id] = this;
this.pageIndex = 1;
this.loadCount = 0;
this.updateGetPath();
let hasPath = this.getPath && this.getPath();
if (!hasPath) {
console.error("Disabling InfiniteScroll");
return;
}
this.updateGetAbsolutePath();
this.log("initialized", [this.element.className]);
this.callOnInit();
for (let method in InfiniteScroll.create) {
InfiniteScroll.create[method].call(this);
}
};
proto.option = function(opts) {
Object.assign(this.options, opts);
};
proto.callOnInit = function() {
let onInit = this.options.onInit;
if (onInit) {
onInit.call(this, this);
}
};
proto.dispatchEvent = function(type, event, args) {
this.log(type, args);
let emitArgs = event ? [event].concat(args) : args;
this.emitEvent(type, emitArgs);
if (!jQuery || !this.$element) {
return;
}
type += ".infiniteScroll";
let $event = type;
if (event) {
let jQEvent = jQuery.Event(event);
jQEvent.type = type;
$event = jQEvent;
}
this.$element.trigger($event, args);
};
let loggers = {
initialized: (className) => `on ${className}`,
request: (path) => `URL: ${path}`,
load: (response, path) => `${response.title || ""}. URL: ${path}`,
error: (error, path) => `${error}. URL: ${path}`,
append: (response, path, items) => `${items.length} items. URL: ${path}`,
last: (response, path) => `URL: ${path}`,
history: (title, path) => `URL: ${path}`,
pageIndex: function(index, origin) {
return `current page determined to be: ${index} from ${origin}`;
}
};
proto.log = function(type, args) {
if (!this.options.debug) return;
let message = `[InfiniteScroll] ${type}`;
let logger = loggers[type];
if (logger) message += ". " + logger.apply(this, args);
console.log(message);
};
proto.updateMeasurements = function() {
this.windowHeight = window2.innerHeight;
let rect = this.element.getBoundingClientRect();
this.top = rect.top + window2.scrollY;
};
proto.updateScroller = function() {
let elementScroll = this.options.elementScroll;
if (!elementScroll) {
this.scroller = window2;
return;
}
this.scroller = elementScroll === true ? this.element : utils.getQueryElement(elementScroll);
if (!this.scroller) {
throw new Error(`Unable to find elementScroll: ${elementScroll}`);
}
};
proto.updateGetPath = function() {
let optPath = this.options.path;
if (!optPath) {
console.error(`InfiniteScroll path option required. Set as: ${optPath}`);
return;
}
let type = typeof optPath;
if (type == "function") {
this.getPath = optPath;
return;
}
let templateMatch = type == "string" && optPath.match("{{#}}");
if (templateMatch) {
this.updateGetPathTemplate(optPath);
return;
}
this.updateGetPathSelector(optPath);
};
proto.updateGetPathTemplate = function(optPath) {
this.getPath = () => {
let nextIndex = this.pageIndex + 1;
return optPath.replace("{{#}}", nextIndex);
};
let regexString = optPath.replace(/(\\\?|\?)/, "\\?").replace("{{#}}", "(\\d\\d?\\d?)");
let templateRe = new RegExp(regexString);
let match = location.href.match(templateRe);
if (match) {
this.pageIndex = parseInt(match[1], 10);
this.log("pageIndex", [this.pageIndex, "template string"]);
}
};
let pathRegexes = [
// WordPress & Tumblr - example.com/page/2
// Jekyll - example.com/page2
/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,
// Drupal - example.com/?page=1
/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,
// catch all, last occurence of a number
/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/
];
let getPathParts = InfiniteScroll.getPathParts = function(href) {
if (!href) return;
for (let regex of pathRegexes) {
let match = href.match(regex);
if (match) {
let [, begin, index, end] = match;
return { begin, index, end };
}
}
};
proto.updateGetPathSelector = function(optPath) {
let hrefElem = document.querySelector(optPath);
if (!hrefElem) {
console.error(`Bad InfiniteScroll path option. Next link not found: ${optPath}`);
return;
}
let href = hrefElem.getAttribute("href");
let pathParts = getPathParts(href);
if (!pathParts) {
console.error(`InfiniteScroll unable to parse next link href: ${href}`);
return;
}
let { begin, index, end } = pathParts;
this.isPathSelector = true;
this.getPath = () => begin + (this.pageIndex + 1) + end;
this.pageIndex = parseInt(index, 10) - 1;
this.log("pageIndex", [this.pageIndex, "next link"]);
};
proto.updateGetAbsolutePath = function() {
let path = this.getPath();
let isAbsolute = path.match(/^http/) || path.match(/^\//);
if (isAbsolute) {
this.getAbsolutePath = this.getPath;
return;
}
let { pathname } = location;
let isQuery = path.match(/^\?/);
let directory = pathname.substring(0, pathname.lastIndexOf("/"));
let pathStart = isQuery ? pathname : directory + "/";
this.getAbsolutePath = () => pathStart + this.getPath();
};
InfiniteScroll.create.hideNav = function() {
let nav = utils.getQueryElement(this.options.hideNav);
if (!nav) return;
nav.style.display = "none";
this.nav = nav;
};
InfiniteScroll.destroy.hideNav = function() {
if (this.nav) this.nav.style.display = "";
};
proto.destroy = function() {
this.allOff();
for (let method in InfiniteScroll.destroy) {
InfiniteScroll.destroy[method].call(this);
}
delete this.element.infiniteScrollGUID;
delete instances[this.guid];
if (jQuery && this.$element) {
jQuery.removeData(this.element, "infiniteScroll");
}
};
InfiniteScroll.throttle = function(fn, threshold) {
threshold = threshold || 200;
let last, timeout;
return function() {
let now = +/* @__PURE__ */ new Date();
let args = arguments;
let trigger = () => {
last = now;
fn.apply(this, args);
};
if (last && now < last + threshold) {
clearTimeout(timeout);
timeout = setTimeout(trigger, threshold);
} else {
trigger();
}
};
};
InfiniteScroll.data = function(elem) {
elem = utils.getQueryElement(elem);
let id = elem && elem.infiniteScrollGUID;
return id && instances[id];
};
InfiniteScroll.setJQuery = function(jqry) {
jQuery = jqry;
};
utils.htmlInit(InfiniteScroll, "infinite-scroll");
proto._init = function() {
};
let { jQueryBridget } = window2;
if (jQuery && jQueryBridget) {
jQueryBridget("infiniteScroll", InfiniteScroll, jQuery);
}
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/page-load.js
var require_page_load = __commonJS({
"node_modules/infinite-scroll/js/page-load.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_core()
);
} else {
factory(
window2,
window2.InfiniteScroll
);
}
})(window, function factory(window2, InfiniteScroll) {
let proto = InfiniteScroll.prototype;
Object.assign(InfiniteScroll.defaults, {
// append: false,
loadOnScroll: true,
checkLastPage: true,
responseBody: "text",
domParseResponse: true
// prefill: false,
// outlayer: null,
});
InfiniteScroll.create.pageLoad = function() {
this.canLoad = true;
this.on("scrollThreshold", this.onScrollThresholdLoad);
this.on("load", this.checkLastPage);
if (this.options.outlayer) {
this.on("append", this.onAppendOutlayer);
}
};
proto.onScrollThresholdLoad = function() {
if (this.options.loadOnScroll) this.loadNextPage();
};
let domParser = new DOMParser();
proto.loadNextPage = function() {
if (this.isLoading || !this.canLoad) return;
let { responseBody, domParseResponse, fetchOptions } = this.options;
let path = this.getAbsolutePath();
this.isLoading = true;
if (typeof fetchOptions == "function") fetchOptions = fetchOptions();
let fetchPromise = fetch(path, fetchOptions).then((response) => {
if (!response.ok) {
let error = new Error(response.statusText);
this.onPageError(error, path, response);
return { response };
}
return response[responseBody]().then((body) => {
let canDomParse = responseBody == "text" && domParseResponse;
if (canDomParse) {
body = domParser.parseFromString(body, "text/html");
}
if (response.status == 204) {
this.lastPageReached(body, path);
return { body, response };
} else {
return this.onPageLoad(body, path, response);
}
});
}).catch((error) => {
this.onPageError(error, path);
});
this.dispatchEvent("request", null, [path, fetchPromise]);
return fetchPromise;
};
proto.onPageLoad = function(body, path, response) {
if (!this.options.append) {
this.isLoading = false;
}
this.pageIndex++;
this.loadCount++;
this.dispatchEvent("load", null, [body, path, response]);
return this.appendNextPage(body, path, response);
};
proto.appendNextPage = function(body, path, response) {
let { append, responseBody, domParseResponse } = this.options;
let isDocument = responseBody == "text" && domParseResponse;
if (!isDocument || !append) return { body, response };
let items = body.querySelectorAll(append);
let promiseValue = { body, response, items };
if (!items || !items.length) {
this.lastPageReached(body, path);
return promiseValue;
}
let fragment = getItemsFragment(items);
let appendReady = () => {
this.appendItems(items, fragment);
this.isLoading = false;
this.dispatchEvent("append", null, [body, path, items, response]);
return promiseValue;
};
if (this.options.outlayer) {
return this.appendOutlayerItems(fragment, appendReady);
} else {
return appendReady();
}
};
proto.appendItems = function(items, fragment) {
if (!items || !items.length) return;
fragment = fragment || getItemsFragment(items);
refreshScripts(fragment);
this.element.appendChild(fragment);
};
function getItemsFragment(items) {
let fragment = document.createDocumentFragment();
if (items) fragment.append(...items);
return fragment;
}
function refreshScripts(fragment) {
let scripts = fragment.querySelectorAll("script");
for (let script of scripts) {
let freshScript = document.createElement("script");
let attrs = script.attributes;
for (let attr of attrs) {
freshScript.setAttribute(attr.name, attr.value);
}
freshScript.innerHTML = script.innerHTML;
script.parentNode.replaceChild(freshScript, script);
}
}
proto.appendOutlayerItems = function(fragment, appendReady) {
let imagesLoaded = InfiniteScroll.imagesLoaded || window2.imagesLoaded;
if (!imagesLoaded) {
console.error("[InfiniteScroll] imagesLoaded required for outlayer option");
this.isLoading = false;
return;
}
return new Promise(function(resolve) {
imagesLoaded(fragment, function() {
let bodyResponse = appendReady();
resolve(bodyResponse);
});
});
};
proto.onAppendOutlayer = function(response, path, items) {
this.options.outlayer.appended(items);
};
proto.checkLastPage = function(body, path) {
let { checkLastPage, path: pathOpt } = this.options;
if (!checkLastPage) return;
if (typeof pathOpt == "function") {
let nextPath = this.getPath();
if (!nextPath) {
this.lastPageReached(body, path);
return;
}
}
let selector;
if (typeof checkLastPage == "string") {
selector = checkLastPage;
} else if (this.isPathSelector) {
selector = pathOpt;
}
if (!selector || !body.querySelector) return;
let nextElem = body.querySelector(selector);
if (!nextElem) this.lastPageReached(body, path);
};
proto.lastPageReached = function(body, path) {
this.canLoad = false;
this.dispatchEvent("last", null, [body, path]);
};
proto.onPageError = function(error, path, response) {
this.isLoading = false;
this.canLoad = false;
this.dispatchEvent("error", null, [error, path, response]);
return error;
};
InfiniteScroll.create.prefill = function() {
if (!this.options.prefill) return;
let append = this.options.append;
if (!append) {
console.error(`append option required for prefill. Set as :${append}`);
return;
}
this.updateMeasurements();
this.updateScroller();
this.isPrefilling = true;
this.on("append", this.prefill);
this.once("error", this.stopPrefill);
this.once("last", this.stopPrefill);
this.prefill();
};
proto.prefill = function() {
let distance = this.getPrefillDistance();
this.isPrefilling = distance >= 0;
if (this.isPrefilling) {
this.log("prefill");
this.loadNextPage();
} else {
this.stopPrefill();
}
};
proto.getPrefillDistance = function() {
if (this.options.elementScroll) {
return this.scroller.clientHeight - this.scroller.scrollHeight;
}
return this.windowHeight - this.element.clientHeight;
};
proto.stopPrefill = function() {
this.log("stopPrefill");
this.off("append", this.prefill);
};
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/scroll-watch.js
var require_scroll_watch = __commonJS({
"node_modules/infinite-scroll/js/scroll-watch.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_core(),
require_utils()
);
} else {
factory(
window2,
window2.InfiniteScroll,
window2.fizzyUIUtils
);
}
})(window, function factory(window2, InfiniteScroll, utils) {
let proto = InfiniteScroll.prototype;
Object.assign(InfiniteScroll.defaults, {
scrollThreshold: 400
// elementScroll: null,
});
InfiniteScroll.create.scrollWatch = function() {
this.pageScrollHandler = this.onPageScroll.bind(this);
this.resizeHandler = this.onResize.bind(this);
let scrollThreshold = this.options.scrollThreshold;
let isEnable = scrollThreshold || scrollThreshold === 0;
if (isEnable) this.enableScrollWatch();
};
InfiniteScroll.destroy.scrollWatch = function() {
this.disableScrollWatch();
};
proto.enableScrollWatch = function() {
if (this.isScrollWatching) return;
this.isScrollWatching = true;
this.updateMeasurements();
this.updateScroller();
this.on("last", this.disableScrollWatch);
this.bindScrollWatchEvents(true);
};
proto.disableScrollWatch = function() {
if (!this.isScrollWatching) return;
this.bindScrollWatchEvents(false);
delete this.isScrollWatching;
};
proto.bindScrollWatchEvents = function(isBind) {
let addRemove = isBind ? "addEventListener" : "removeEventListener";
this.scroller[addRemove]("scroll", this.pageScrollHandler);
window2[addRemove]("resize", this.resizeHandler);
};
proto.onPageScroll = InfiniteScroll.throttle(function() {
let distance = this.getBottomDistance();
if (distance <= this.options.scrollThreshold) {
this.dispatchEvent("scrollThreshold");
}
});
proto.getBottomDistance = function() {
let bottom, scrollY;
if (this.options.elementScroll) {
bottom = this.scroller.scrollHeight;
scrollY = this.scroller.scrollTop + this.scroller.clientHeight;
} else {
bottom = this.top + this.element.clientHeight;
scrollY = window2.scrollY + this.windowHeight;
}
return bottom - scrollY;
};
proto.onResize = function() {
this.updateMeasurements();
};
utils.debounceMethod(InfiniteScroll, "onResize", 150);
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/history.js
var require_history = __commonJS({
"node_modules/infinite-scroll/js/history.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_core(),
require_utils()
);
} else {
factory(
window2,
window2.InfiniteScroll,
window2.fizzyUIUtils
);
}
})(window, function factory(window2, InfiniteScroll, utils) {
let proto = InfiniteScroll.prototype;
Object.assign(InfiniteScroll.defaults, {
history: "replace"
// historyTitle: false,
});
let link = document.createElement("a");
InfiniteScroll.create.history = function() {
if (!this.options.history) return;
link.href = this.getAbsolutePath();
let linkOrigin = link.origin || link.protocol + "//" + link.host;
let isSameOrigin = linkOrigin == location.origin;
if (!isSameOrigin) {
console.error(`[InfiniteScroll] cannot set history with different origin: ${link.origin} on ${location.origin} . History behavior disabled.`);
return;
}
if (this.options.append) {
this.createHistoryAppend();
} else {
this.createHistoryPageLoad();
}
};
proto.createHistoryAppend = function() {
this.updateMeasurements();
this.updateScroller();
this.scrollPages = [
// first page
{
top: 0,
path: location.href,
title: document.title
}
];
this.scrollPage = this.scrollPages[0];
this.scrollHistoryHandler = this.onScrollHistory.bind(this);
this.unloadHandler = this.onUnload.bind(this);
this.scroller.addEventListener("scroll", this.scrollHistoryHandler);
this.on("append", this.onAppendHistory);
this.bindHistoryAppendEvents(true);
};
proto.bindHistoryAppendEvents = function(isBind) {
let addRemove = isBind ? "addEventListener" : "removeEventListener";
this.scroller[addRemove]("scroll", this.scrollHistoryHandler);
window2[addRemove]("unload", this.unloadHandler);
};
proto.createHistoryPageLoad = function() {
this.on("load", this.onPageLoadHistory);
};
InfiniteScroll.destroy.history = proto.destroyHistory = function() {
let isHistoryAppend = this.options.history && this.options.append;
if (isHistoryAppend) {
this.bindHistoryAppendEvents(false);
}
};
proto.onAppendHistory = function(response, path, items) {
if (!items || !items.length) return;
let firstItem = items[0];
let elemScrollY = this.getElementScrollY(firstItem);
link.href = path;
this.scrollPages.push({
top: elemScrollY,
path: link.href,
title: response.title
});
};
proto.getElementScrollY = function(elem) {
if (this.options.elementScroll) {
return elem.offsetTop - this.top;
} else {
let rect = elem.getBoundingClientRect();
return rect.top + window2.scrollY;
}
};
proto.onScrollHistory = function() {
let scrollPage = this.getClosestScrollPage();
if (scrollPage != this.scrollPage) {
this.scrollPage = scrollPage;
this.setHistory(scrollPage.title, scrollPage.path);
}
};
utils.debounceMethod(InfiniteScroll, "onScrollHistory", 150);
proto.getClosestScrollPage = function() {
let scrollViewY;
if (this.options.elementScroll) {
scrollViewY = this.scroller.scrollTop + this.scroller.clientHeight / 2;
} else {
scrollViewY = window2.scrollY + this.windowHeight / 2;
}
let scrollPage;
for (let page of this.scrollPages) {
if (page.top >= scrollViewY) break;
scrollPage = page;
}
return scrollPage;
};
proto.setHistory = function(title, path) {
let optHistory = this.options.history;
let historyMethod = optHistory && history[optHistory + "State"];
if (!historyMethod) return;
history[optHistory + "State"](null, title, path);
if (this.options.historyTitle) document.title = title;
this.dispatchEvent("history", null, [title, path]);
};
proto.onUnload = function() {
if (this.scrollPage.top === 0) return;
let scrollY = window2.scrollY - this.scrollPage.top + this.top;
this.destroyHistory();
scrollTo(0, scrollY);
};
proto.onPageLoadHistory = function(response, path) {
this.setHistory(response.title, path);
};
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/button.js
var require_button = __commonJS({
"node_modules/infinite-scroll/js/button.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_core(),
require_utils()
);
} else {
factory(
window2,
window2.InfiniteScroll,
window2.fizzyUIUtils
);
}
})(window, function factory(window2, InfiniteScroll, utils) {
class InfiniteScrollButton {
constructor(element, infScroll) {
this.element = element;
this.infScroll = infScroll;
this.clickHandler = this.onClick.bind(this);
this.element.addEventListener("click", this.clickHandler);
infScroll.on("request", this.disable.bind(this));
infScroll.on("load", this.enable.bind(this));
infScroll.on("error", this.hide.bind(this));
infScroll.on("last", this.hide.bind(this));
}
onClick(event) {
event.preventDefault();
this.infScroll.loadNextPage();
}
enable() {
this.element.removeAttribute("disabled");
}
disable() {
this.element.disabled = "disabled";
}
hide() {
this.element.style.display = "none";
}
destroy() {
this.element.removeEventListener("click", this.clickHandler);
}
}
InfiniteScroll.create.button = function() {
let buttonElem = utils.getQueryElement(this.options.button);
if (buttonElem) {
this.button = new InfiniteScrollButton(buttonElem, this);
}
};
InfiniteScroll.destroy.button = function() {
if (this.button) this.button.destroy();
};
InfiniteScroll.Button = InfiniteScrollButton;
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/status.js
var require_status = __commonJS({
"node_modules/infinite-scroll/js/status.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
window2,
require_core(),
require_utils()
);
} else {
factory(
window2,
window2.InfiniteScroll,
window2.fizzyUIUtils
);
}
})(window, function factory(window2, InfiniteScroll, utils) {
let proto = InfiniteScroll.prototype;
InfiniteScroll.create.status = function() {
let statusElem = utils.getQueryElement(this.options.status);
if (!statusElem) return;
this.statusElement = statusElem;
this.statusEventElements = {
request: statusElem.querySelector(".infinite-scroll-request"),
error: statusElem.querySelector(".infinite-scroll-error"),
last: statusElem.querySelector(".infinite-scroll-last")
};
this.on("request", this.showRequestStatus);
this.on("error", this.showErrorStatus);
this.on("last", this.showLastStatus);
this.bindHideStatus("on");
};
proto.bindHideStatus = function(bindMethod) {
let hideEvent = this.options.append ? "append" : "load";
this[bindMethod](hideEvent, this.hideAllStatus);
};
proto.showRequestStatus = function() {
this.showStatus("request");
};
proto.showErrorStatus = function() {
this.showStatus("error");
};
proto.showLastStatus = function() {
this.showStatus("last");
this.bindHideStatus("off");
};
proto.showStatus = function(eventName) {
show(this.statusElement);
this.hideStatusEventElements();
let eventElem = this.statusEventElements[eventName];
show(eventElem);
};
proto.hideAllStatus = function() {
hide(this.statusElement);
this.hideStatusEventElements();
};
proto.hideStatusEventElements = function() {
for (let type in this.statusEventElements) {
let eventElem = this.statusEventElements[type];
hide(eventElem);
}
};
function hide(elem) {
setDisplay(elem, "none");
}
function show(elem) {
setDisplay(elem, "block");
}
function setDisplay(elem, value) {
if (elem) {
elem.style.display = value;
}
}
return InfiniteScroll;
});
}
});
// node_modules/infinite-scroll/js/index.js
var require_js = __commonJS({
"node_modules/infinite-scroll/js/index.js"(exports, module) {
(function(window2, factory) {
if (typeof module == "object" && module.exports) {
module.exports = factory(
require_core(),
require_page_load(),
require_scroll_watch(),
require_history(),
require_button(),
require_status()
);
}
})(window, function factory(InfiniteScroll) {
return InfiniteScroll;
});
}
});
export default require_js();
//# sourceMappingURL=infinite-scroll.js.map