UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Microsoft 365.

44 lines 1.52 kB
define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.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.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.setScrollYPosition = function (el, pos) { if ('scrollTop' in el) { el.scrollTop = pos; } else if ('scrollY' in el) { el.scrollTo(el.scrollX, pos); } }; }); //# sourceMappingURL=scroll.js.map