UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

50 lines (48 loc) 1.77 kB
/** * DevExtreme (cjs/__internal/ui/overlay/utils.js) * Version: 25.2.3 * Build date: Fri Dec 12 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getElementMaxHeightByWindow = void 0; var _renderer = _interopRequireDefault(require("../../../core/renderer")); var _size = require("../../../core/utils/size"); var _type = require("../../../core/utils/type"); var _m_window = require("../../core/utils/m_window"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const WINDOW_HEIGHT_PERCENT = .9; const getElementMaxHeightByWindow = ($element, startLocation) => { const offset = $element.offset(); if (void 0 === offset) { return } const $window = (0, _renderer.default)((0, _m_window.getWindow)()); const { top: elementOffset } = offset; let actualOffset = 0; const windowScrollTop = $window.scrollTop(); const windowHeight = (0, _size.getInnerHeight)($window); if ((0, _type.isNumeric)(startLocation)) { if (startLocation < elementOffset) { return elementOffset - startLocation } actualOffset = windowHeight - startLocation + windowScrollTop } else { const offsetTop = elementOffset - windowScrollTop; const offsetBottom = windowHeight - offsetTop - (0, _size.getOuterHeight)($element); actualOffset = Math.max(offsetTop, offsetBottom) } return .9 * actualOffset }; exports.getElementMaxHeightByWindow = getElementMaxHeightByWindow;