UNPKG

@fluentui/react

Version:

Reusable React components for building web experiences.

48 lines 1.76 kB
define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setScrollYPosition = exports.getScrollYPosition = exports.getScrollHeight = void 0; var getScrollHeight = function (el) { if (el === undefined) { return 0; } var scrollHeight = 0; if ('scrollHeight' in el) { scrollHeight = el.scrollHeight; } else if ('document' in el) { scrollHeight = el.document.documentElement.scrollHeight; } // No need to round as scrollHeight is already rounded for us. // See: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight return scrollHeight; }; exports.getScrollHeight = getScrollHeight; var getScrollYPosition = function (el) { if (el === undefined) { return 0; } var scrollPos = 0; if ('scrollTop' in el) { scrollPos = el.scrollTop; } else if ('scrollY' in el) { scrollPos = el.scrollY; } // Round this value to an integer as it may be fractional. // See: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop // See: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY return Math.ceil(scrollPos); }; exports.getScrollYPosition = getScrollYPosition; var setScrollYPosition = function (el, pos) { if ('scrollTop' in el) { el.scrollTop = pos; } else if ('scrollY' in el) { el.scrollTo(el.scrollX, pos); } }; exports.setScrollYPosition = setScrollYPosition; }); //# sourceMappingURL=scroll.js.map