UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

45 lines (44 loc) 1.42 kB
/** * DevExtreme (esm/__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/ */ import $ from "../../../core/renderer"; import { getInnerHeight, getOuterHeight } from "../../../core/utils/size"; import { isNumeric } from "../../../core/utils/type"; import { getWindow } from "../../core/utils/m_window"; const WINDOW_HEIGHT_PERCENT = .9; export const getElementMaxHeightByWindow = ($element, startLocation) => { const offset = $element.offset(); if (void 0 === offset) { return } const $window = $(getWindow()); const { top: elementOffset } = offset; let actualOffset = 0; const windowScrollTop = $window.scrollTop(); const windowHeight = getInnerHeight($window); if (isNumeric(startLocation)) { if (startLocation < elementOffset) { return elementOffset - startLocation } actualOffset = windowHeight - startLocation + windowScrollTop } else { const offsetTop = elementOffset - windowScrollTop; const offsetBottom = windowHeight - offsetTop - getOuterHeight($element); actualOffset = Math.max(offsetTop, offsetBottom) } return .9 * actualOffset };