UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

37 lines (36 loc) 1.27 kB
/** * DevExtreme (esm/__internal/ui/overlay/m_utils.js) * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import $ from "../../../core/renderer"; import { getInnerHeight, getOuterHeight } from "../../../core/utils/size"; import { isNumeric } from "../../../core/utils/type"; import windowUtils from "../../core/utils/m_window"; const WINDOW_HEIGHT_PERCENT = .9; export const getElementMaxHeightByWindow = ($element, startLocation) => { const $window = $(windowUtils.getWindow()); const { top: elementOffset } = $element.offset(); let actualOffset; if (isNumeric(startLocation)) { if (startLocation < elementOffset) { return elementOffset - startLocation } actualOffset = getInnerHeight($window) - startLocation + $window.scrollTop() } else { const offsetTop = elementOffset - $window.scrollTop(); const offsetBottom = getInnerHeight($window) - offsetTop - getOuterHeight($element); actualOffset = Math.max(offsetTop, offsetBottom) } return .9 * actualOffset };