54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// src/_util/getScroll.ts
|
|
var getScroll_exports = {};
|
|
__export(getScroll_exports, {
|
|
default: () => getScroll,
|
|
isWindow: () => isWindow
|
|
});
|
|
module.exports = __toCommonJS(getScroll_exports);
|
|
function isWindow(obj) {
|
|
return obj !== null && obj !== void 0 && obj === obj.window;
|
|
}
|
|
function getScroll(target, top) {
|
|
var _a;
|
|
if (typeof window === "undefined") {
|
|
return 0;
|
|
}
|
|
const method = top ? "scrollTop" : "scrollLeft";
|
|
let result = 0;
|
|
if (isWindow(target)) {
|
|
result = target[top ? "pageYOffset" : "pageXOffset"];
|
|
} else if (target instanceof Document) {
|
|
result = target.documentElement[method];
|
|
} else if (target instanceof HTMLElement) {
|
|
result = target[method];
|
|
} else if (target) {
|
|
result = target[method];
|
|
}
|
|
if (target && !isWindow(target) && typeof result !== "number") {
|
|
result = (_a = (target.ownerDocument ?? target).documentElement) == null ? void 0 : _a[method];
|
|
}
|
|
return result;
|
|
}
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
isWindow
|
|
});
|