UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

128 lines (127 loc) 3.66 kB
/** * DevExtreme (esm/__internal/scheduler/tooltip_strategies/mobile_tooltip_strategy.js) * Version: 26.1.3 * Build date: Wed Jun 10 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { getHeight, getOuterHeight, getWidth } from "../../../core/utils/size"; import { getWindow } from "../../../core/utils/window"; import Overlay from "../../../ui/overlay/ui.overlay"; import { TooltipStrategyBase } from "./tooltip_strategy_base"; const CLASS = { slidePanel: "dx-scheduler-overlay-panel", scrollableContent: ".dx-scrollable-content" }; const MAX_TABLET_OVERLAY_HEIGHT_FACTOR = .9; const MAX_HEIGHT = { PHONE: 250, TABLET: "90%", DEFAULT: "auto" }; const MAX_WIDTH = { PHONE: "100%", TABLET: "80%" }; const animationConfig = { show: { type: "slide", duration: 300, from: { position: { my: "top", at: "bottom", of: getWindow() } }, to: { position: { my: "center", at: "center", of: getWindow() } } }, hide: { type: "slide", duration: 300, to: { position: { my: "top", at: "bottom", of: getWindow() } }, from: { position: { my: "center", at: "center", of: getWindow() } } } }; const createPhoneDeviceConfig = listHeight => ({ shading: false, width: MAX_WIDTH.PHONE, height: listHeight > MAX_HEIGHT.PHONE ? MAX_HEIGHT.PHONE : MAX_HEIGHT.DEFAULT, position: { my: "bottom", at: "bottom", of: getWindow() } }); const createTabletDeviceConfig = listHeight => { const currentMaxHeight = .9 * getHeight(getWindow()); return { shading: true, width: MAX_WIDTH.TABLET, height: listHeight > currentMaxHeight ? MAX_HEIGHT.TABLET : MAX_HEIGHT.DEFAULT, position: { my: "center", at: "center", of: getWindow() } } }; export class MobileTooltipStrategy extends TooltipStrategyBase { isDesktop() { return false } setTooltipConfig() { var _this$tooltip; const isTabletWidth = getWidth(getWindow()) > 700; const listHeight = getOuterHeight(this.list.$element().find(CLASS.scrollableContent)); null === (_this$tooltip = this.tooltip) || void 0 === _this$tooltip || _this$tooltip.option(isTabletWidth ? createTabletDeviceConfig(listHeight) : createPhoneDeviceConfig(listHeight)) } async onShowing() { var _this$tooltip2; null === (_this$tooltip2 = this.tooltip) || void 0 === _this$tooltip2 || _this$tooltip2.option("height", MAX_HEIGHT.DEFAULT); this.setTooltipConfig(); await Promise.all([...this.asyncTemplatePromises]); this.setTooltipConfig() } createTooltip(dataList) { const element = this.createTooltipElement(CLASS.slidePanel); return this._options.createComponent(element, Overlay, { target: getWindow(), hideOnOutsideClick: true, animation: animationConfig, onShowing: () => this.onShowing(), onShown: this.onShown.bind(this), contentTemplate: this.getContentTemplate(dataList), wrapperAttr: { class: CLASS.slidePanel } }) } }