UNPKG

ant-design-vue

Version:

An enterprise-class UI design language and Vue-based implementation

36 lines (28 loc) 841 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getScroll; exports.isWindow = isWindow; function isWindow(obj) { return obj !== null && obj !== undefined && obj === obj.window; } function getScroll(target, top) { var _a; if (typeof window === 'undefined') { return 0; } var method = top ? 'scrollTop' : 'scrollLeft'; var result = 0; if (isWindow(target)) { result = target[top ? 'pageYOffset' : 'pageXOffset']; } else if (target instanceof Document) { result = target.documentElement[method]; } else if (target) { result = target[method]; } if (target && !isWindow(target) && typeof result !== 'number') { result = (_a = (target.ownerDocument || target).documentElement) === null || _a === void 0 ? void 0 : _a[method]; } return result; }