@syncfusion/ej2-schedule 24.2.3 → 24.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6666,6 +6666,9 @@ class EventBase {
6666
6666
  }
6667
6667
  }
6668
6668
  }
6669
+ getCellWidth(element) {
6670
+ return document.body.style.transform.includes('scale') ? parseFloat(window.getComputedStyle(element).width) : element.getBoundingClientRect().width;
6671
+ }
6669
6672
  unWireEvents() {
6670
6673
  const appElements = [].slice.call(this.parent.element.querySelectorAll('.' + APPOINTMENT_CLASS));
6671
6674
  for (const element of appElements) {
@@ -7641,10 +7644,9 @@ class MonthEvent extends EventBase {
7641
7644
  setStyleAttribute(cell, { 'height': height + 'px' });
7642
7645
  });
7643
7646
  }
7644
- const cellDetail = this.workCells[this.parent.activeView.isTimelineView() ?
7645
- 0 : this.workCells.length - 1].getBoundingClientRect();
7646
- this.cellWidth = cellDetail.width;
7647
- this.cellHeight = cellDetail.height;
7647
+ const cellDetail = this.workCells[this.parent.activeView.isTimelineView() ? 0 : this.workCells.length - 1];
7648
+ this.cellWidth = this.parent.eventBase.getCellWidth(cellDetail);
7649
+ this.cellHeight = cellDetail.getBoundingClientRect().height;
7648
7650
  this.dateRender = dateRender;
7649
7651
  const filteredDates = this.getRenderedDates(dateRender);
7650
7652
  this.getSlotDates(workDays || this.parent.activeViewOptions.workDays);
@@ -8384,8 +8386,11 @@ class TimelineEvent extends MonthEvent {
8384
8386
  this.slotCount / this.interval;
8385
8387
  for (let k = 0; k < slotCount; k++) {
8386
8388
  startDate = (k === 0) ? new Date(startDate.getTime()) : new Date(startDate.getTime() + (60000 * interval));
8389
+ if (slotCount < 1) {
8390
+ startDate = this.adjustToNearestTimeSlot(startDate, interval);
8391
+ }
8387
8392
  endDate = new Date(startDate.getTime() + (60000 * interval));
8388
- if (endDate.getTime() > endTime.getTime()) {
8393
+ if (slotCount >= 1 && endDate.getTime() > endTime.getTime()) {
8389
8394
  break;
8390
8395
  }
8391
8396
  const position = this.getPosition(startDate, endDate, false, (this.day + i));
@@ -8401,6 +8406,20 @@ class TimelineEvent extends MonthEvent {
8401
8406
  }
8402
8407
  this.parent.renderTemplates();
8403
8408
  }
8409
+ adjustToNearestTimeSlot(inputTime, interval) {
8410
+ // Parse the input time
8411
+ const parsedTime = new Date(inputTime);
8412
+ // Get the minutes of the input time in milliseconds
8413
+ const minutesInMilliseconds = parsedTime.getHours() * 60 * 60 * 1000 + parsedTime.getMinutes() * 60 * 1000;
8414
+ // Calculate the adjusted time in milliseconds (nearest time slot)
8415
+ const adjustedMinutesInMilliseconds = Math.floor(minutesInMilliseconds / (interval * 60 * 1000)) * (interval * 60 * 1000);
8416
+ // Create a new Date object with the adjusted time
8417
+ const adjustedTime = new Date(parsedTime.getTime());
8418
+ adjustedTime.setHours(adjustedMinutesInMilliseconds / (60 * 60 * 1000) % 24);
8419
+ adjustedTime.setMinutes((adjustedMinutesInMilliseconds % (60 * 60 * 1000)) / (60 * 1000));
8420
+ // Return the adjusted time in string format
8421
+ return adjustedTime;
8422
+ }
8404
8423
  renderTimelineMoreIndicator(startTime, startDate, endDate, appHeight, interval, resIndex, appointmentsList, top, appLeft, appRight, cellTd, moreIndicator, appPos, position) {
8405
8424
  appLeft = (this.parent.enableRtl) ? appRight = position : position;
8406
8425
  appPos = (this.parent.enableRtl) ? appRight : appLeft;
@@ -8459,8 +8478,9 @@ class TimelineEvent extends MonthEvent {
8459
8478
  }
8460
8479
  adjustAppointments(conWidth) {
8461
8480
  const tr = this.parent.element.querySelector('.' + CONTENT_TABLE_CLASS + ' tbody tr');
8462
- this.cellWidth = this.workCells[0].getBoundingClientRect().width;
8463
- const currentPercentage = (this.cellWidth * tr.children.length) / (conWidth / 100);
8481
+ const actualCellWidth = this.workCells[0].getBoundingClientRect().width;
8482
+ this.cellWidth = actualCellWidth / +(this.workCells[0].getAttribute('colspan') || 1);
8483
+ const currentPercentage = (actualCellWidth * tr.children.length) / (conWidth / 100);
8464
8484
  const apps = [].slice.call(this.parent.element.querySelectorAll('.' + APPOINTMENT_CLASS));
8465
8485
  apps.forEach((app) => {
8466
8486
  if (this.parent.enableRtl && app.style.right !== '0px') {
@@ -20345,7 +20365,12 @@ class Resize extends ActionBase {
20345
20365
  const left = (this.parent.enableRtl) ? parseInt(this.actionObj.element.style.right, 10) : this.actionObj.clone.offsetLeft;
20346
20366
  if (isTimeViews) {
20347
20367
  offsetWidth = targetWidth + (Math.ceil(pageWidth / slotInterval) * slotInterval);
20348
- offsetWidth = (Math.round((left + offsetWidth) / slotInterval) * slotInterval) - left;
20368
+ if (!isLeft) {
20369
+ const roundedLeft = (+parseFloat(this.actionObj.element.style[this.parent.enableRtl ? 'right' : 'left'])).toFixed(1);
20370
+ if (roundedLeft !== left.toFixed(1)) {
20371
+ offsetWidth = (Math.round((left + offsetWidth) / slotInterval) * slotInterval) - left;
20372
+ }
20373
+ }
20349
20374
  this.actionObj.event[this.parent.eventFields.isAllDay] = false;
20350
20375
  }
20351
20376
  let width = !isLeft && ((offsetWidth + this.actionObj.clone.offsetLeft > this.scrollArgs.width)) ?
@@ -20355,9 +20380,11 @@ class Resize extends ActionBase {
20355
20380
  -(offsetWidth - this.actionObj.cellWidth);
20356
20381
  rightValue = isTimelineView ? rightValue : isLeft ? 0 : rightValue > 0 ? 0 : rightValue;
20357
20382
  if (isTimelineView && !isLeft) {
20358
- rightValue = Math.ceil((this.actionObj.element.offsetLeft + (this.actionObj.element.getBoundingClientRect().width +
20359
- (this.actionObj.pageX - this.actionObj.X))) / slotInterval) * slotInterval;
20360
- rightValue = rightValue < 0 ? Math.abs(rightValue) : -rightValue;
20383
+ rightValue = rightValue - (Math.ceil((this.actionObj.pageX - this.actionObj.X) / slotInterval) * slotInterval);
20384
+ if (rightValue < 0) {
20385
+ rightValue = parseInt(this.actionObj.clone.style.right, 10);
20386
+ width = parseInt(this.actionObj.clone.style.width, 10);
20387
+ }
20361
20388
  }
20362
20389
  rightValue = rightValue >= this.scrollArgs.width ? this.scrollArgs.width - this.actionObj.cellWidth : rightValue;
20363
20390
  styles.right = formatUnit(rightValue);
@@ -20379,12 +20406,19 @@ class Resize extends ActionBase {
20379
20406
  }
20380
20407
  }
20381
20408
  const leftValue = offsetLeft;
20382
- offsetLeft = isTimelineView ? isTimeViews ? isLeft ? Math.floor(offsetLeft / slotInterval) * slotInterval : offsetLeft :
20409
+ offsetLeft = isTimelineView ? isTimeViews ? isLeft ? this.actionObj.element.offsetLeft -
20410
+ (Math.ceil((this.actionObj.element.offsetLeft - offsetLeft) / slotInterval) * slotInterval) : offsetLeft :
20383
20411
  Math.floor(offsetLeft / this.actionObj.cellWidth) * this.actionObj.cellWidth :
20384
20412
  Math.ceil(Math.abs(offsetLeft) / this.actionObj.cellWidth) * this.actionObj.cellWidth;
20385
20413
  if (offsetLeft < 0) {
20386
- offsetLeft = 0;
20387
- width = this.actionObj.clone.getBoundingClientRect().width;
20414
+ if (isTimelineView && isLeft && (offsetLeft % slotInterval)) {
20415
+ offsetLeft = parseInt(this.actionObj.clone.style.left, 10);
20416
+ width = parseInt(this.actionObj.clone.style.width, 10);
20417
+ }
20418
+ else {
20419
+ offsetLeft = 0;
20420
+ width = this.actionObj.clone.getBoundingClientRect().width;
20421
+ }
20388
20422
  }
20389
20423
  const cloneWidth = Math.ceil(this.actionObj.clone.getBoundingClientRect().width / this.actionObj.cellWidth) *
20390
20424
  this.actionObj.cellWidth;
@@ -20499,7 +20533,7 @@ class YearEvent extends TimelineEvent {
20499
20533
  }
20500
20534
  timelineYearViewEvents() {
20501
20535
  const workCell = this.parent.element.querySelector('.' + WORK_CELLS_CLASS + ':not(.' + OTHERMONTH_CLASS + ')');
20502
- this.cellWidth = workCell.getBoundingClientRect().width;
20536
+ this.cellWidth = this.parent.eventBase.getCellWidth(workCell);
20503
20537
  this.cellHeader = getOuterHeight(workCell.querySelector('.' + DATE_HEADER_CLASS));
20504
20538
  const eventTable = this.parent.element.querySelector('.' + EVENT_TABLE_CLASS);
20505
20539
  this.eventHeight = getElementHeightFromClass(eventTable, APPOINTMENT_CLASS);
@@ -22031,13 +22065,20 @@ class DragAndDrop extends ActionBase {
22031
22065
  if (this.isStepDragging) {
22032
22066
  const widthDiff = this.getWidthDiff(tr, index);
22033
22067
  if (widthDiff !== 0) {
22034
- const timeDiff = Math.round(widthDiff / this.widthPerMinute);
22068
+ let timeDiff = Math.ceil(widthDiff / this.widthPerMinute);
22035
22069
  eventStart.setMinutes(eventStart.getMinutes() + (timeDiff * this.actionObj.interval));
22036
22070
  if (this.isCursorAhead || cursorDrag) {
22037
22071
  eventStart.setMilliseconds(-(eventDuration));
22038
22072
  }
22039
22073
  else {
22040
22074
  eventStart.setMinutes(eventStart.getMinutes() - this.minDiff);
22075
+ const intervalInMS = this.actionObj.interval * MS_PER_MINUTE;
22076
+ timeDiff = Math.abs(eventStart.getTime() - this.actionObj.start.getTime()) / intervalInMS;
22077
+ const roundTimeDiff = Math.trunc(timeDiff);
22078
+ if (roundTimeDiff !== timeDiff) {
22079
+ timeDiff = (roundTimeDiff * intervalInMS) * (eventStart > this.actionObj.start ? 1 : -1);
22080
+ eventStart = new Date(this.actionObj.start.getTime() + timeDiff);
22081
+ }
22041
22082
  }
22042
22083
  }
22043
22084
  else {
@@ -22058,7 +22099,9 @@ class DragAndDrop extends ActionBase {
22058
22099
  (this.cursorPointIndex * (this.isTimelineDayProcess ? MINUTES_PER_DAY : this.actionObj.slotInterval)));
22059
22100
  }
22060
22101
  }
22061
- eventStart = this.calculateIntervalTime(eventStart);
22102
+ if (!this.isStepDragging) {
22103
+ eventStart = this.calculateIntervalTime(eventStart);
22104
+ }
22062
22105
  if (this.isTimelineDayProcess) {
22063
22106
  const eventSrt = eventObj[this.parent.eventFields.startTime];
22064
22107
  eventStart.setHours(eventSrt.getHours(), eventSrt.getMinutes(), eventSrt.getSeconds());