UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

42 lines (40 loc) 1.56 kB
/** * DevExtreme (cjs/ui/overlay/utils.js) * Version: 23.2.6 * Build date: Wed May 01 2024 * * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; exports.getElementMaxHeightByWindow = void 0; var _size = require("../../core/utils/size"); var _renderer = _interopRequireDefault(require("../../core/renderer")); var _window = require("../../core/utils/window"); var _type = require("../../core/utils/type"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } const WINDOW_HEIGHT_PERCENT = .9; const getElementMaxHeightByWindow = ($element, startLocation) => { const $window = (0, _renderer.default)((0, _window.getWindow)()); const { top: elementOffset } = $element.offset(); let actualOffset; if ((0, _type.isNumeric)(startLocation)) { if (startLocation < elementOffset) { return elementOffset - startLocation } else { actualOffset = (0, _size.getInnerHeight)($window) - startLocation + $window.scrollTop() } } else { const offsetTop = elementOffset - $window.scrollTop(); const offsetBottom = (0, _size.getInnerHeight)($window) - offsetTop - (0, _size.getOuterHeight)($element); actualOffset = Math.max(offsetTop, offsetBottom) } return .9 * actualOffset }; exports.getElementMaxHeightByWindow = getElementMaxHeightByWindow;