UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

51 lines (50 loc) • 1.63 kB
const TOAST_DODGE_DURATION = "608ms"; const TOAST_DODGE_EASE = "linear(0, 0.08, 0.249, 0.437, 0.607, 0.745, 0.847, 0.917, 0.963, 0.99, 1.004, 1.011, 1.012, 1.011, 1.009, 1.007, 1.005, 1.003, 1.002, 1)"; const TOAST_SHIFT_X_VAR = "--toast-shift-x"; const TOAST_SHIFT_Y_VAR = "--toast-shift-y"; const TOAST_WIDTH_VAR = "--toast-width"; const PANEL_RESERVE_VAR = "--floating-panel-reserve-block-end"; const PANEL_ALIGN_INLINE_VAR = "--floating-panel-reserve-inline-end"; const resolveToastDodge = ({ panelHeight, panelOffsetX, panelOffsetY, panelWidth, viewportHeight, viewportWidth }) => { const shiftX = Math.max(0, panelWidth + panelOffsetX + 12 - 16); const shiftY = Math.max(0, panelHeight + panelOffsetY + 12 - 16); const lane = viewportWidth - shiftX - 32; const headroom = viewportHeight - shiftY - 32; const alignBlock = Math.max(0, 16 - panelOffsetY); const alignInline = Math.max(0, 16 - panelOffsetX); if (lane >= 360) return { alignInline: 0, mode: "left", reserve: alignBlock, shiftX, shiftY: 0, width: 360 }; if (headroom >= 88) return { alignInline, mode: "up", reserve: 0, shiftX: 0, shiftY, width: 360 }; if (lane >= 260) return { alignInline: 0, mode: "shrink", reserve: alignBlock, shiftX, shiftY: 0, width: lane }; return { alignInline, mode: "reserve", reserve: Math.max(0, 116 - panelOffsetY), shiftX: 0, shiftY: 0, width: 360 }; }; //#endregion export { PANEL_ALIGN_INLINE_VAR, PANEL_RESERVE_VAR, TOAST_DODGE_DURATION, TOAST_DODGE_EASE, TOAST_SHIFT_X_VAR, TOAST_SHIFT_Y_VAR, TOAST_WIDTH_VAR, resolveToastDodge }; //# sourceMappingURL=dodge.mjs.map