UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

65 lines (63 loc) 2.42 kB
/** * DevExtreme (cjs/__internal/scheduler/appointments/resizing/get_delta_time.js) * Version: 25.2.7 * Build date: Tue May 05 2026 * * Copyright (c) 2012 - 2026 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.getDeltaTime = void 0; var _date = _interopRequireDefault(require("../../../../core/utils/date")); var _constants = require("../../constants"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } const toMs = _date.default.dateToMilliseconds; const MIN_RESIZABLE_STEP = 2; const getAllDayDeltaWidth = (args, initialSize, resizableStep) => { const intervalWidth = resizableStep || 2; const initialWidth = initialSize.width; return Math.round((args.width - initialWidth) / intervalWidth) }; const getHorizontalDeltaTime = (args, initialSize, _ref) => { let { cellSize: cellSize, cellDurationInMinutes: cellDurationInMinutes } = _ref; const deltaWidth = args.width - initialSize.width; const deltaTime = toMs("minute") * Math.round(deltaWidth * cellDurationInMinutes / cellSize.width); return deltaTime }; const getVerticalDeltaTime = (args, initialSize, _ref2) => { let { cellSize: cellSize, cellDurationInMinutes: cellDurationInMinutes } = _ref2; const deltaHeight = args.height - initialSize.height; const deltaTime = toMs("minute") * Math.round(deltaHeight * cellDurationInMinutes / cellSize.height); return deltaTime }; const getDeltaTime = (args, initialSize, options) => { const { viewType: viewType, resizableStep: resizableStep, isAllDayPanel: isAllDayPanel } = options; switch (true) { case ["timelineMonth", "month"].includes(viewType) || Boolean(isAllDayPanel): return getAllDayDeltaWidth(args, initialSize, resizableStep) * toMs("day"); case "agenda" === viewType: return 0; case _constants.VERTICAL_VIEW_TYPES.includes(viewType) && !isAllDayPanel: return getVerticalDeltaTime(args, initialSize, options); default: return getHorizontalDeltaTime(args, initialSize, options) } }; exports.getDeltaTime = getDeltaTime;