@syncfusion/ej2-schedule 24.1.41 → 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.
@@ -6784,6 +6784,9 @@ var EventBase = /** @__PURE__ @class */ (function () {
6784
6784
  }
6785
6785
  }
6786
6786
  };
6787
+ EventBase.prototype.getCellWidth = function (element) {
6788
+ return document.body.style.transform.includes('scale') ? parseFloat(window.getComputedStyle(element).width) : element.getBoundingClientRect().width;
6789
+ };
6787
6790
  EventBase.prototype.unWireEvents = function () {
6788
6791
  var appElements = [].slice.call(this.parent.element.querySelectorAll('.' + APPOINTMENT_CLASS));
6789
6792
  for (var _i = 0, appElements_1 = appElements; _i < appElements_1.length; _i++) {
@@ -7824,10 +7827,9 @@ var MonthEvent = /** @__PURE__ @class */ (function (_super) {
7824
7827
  setStyleAttribute(cell, { 'height': height_1 + 'px' });
7825
7828
  });
7826
7829
  }
7827
- var cellDetail = this.workCells[this.parent.activeView.isTimelineView() ?
7828
- 0 : this.workCells.length - 1].getBoundingClientRect();
7829
- this.cellWidth = cellDetail.width;
7830
- this.cellHeight = cellDetail.height;
7830
+ var cellDetail = this.workCells[this.parent.activeView.isTimelineView() ? 0 : this.workCells.length - 1];
7831
+ this.cellWidth = this.parent.eventBase.getCellWidth(cellDetail);
7832
+ this.cellHeight = cellDetail.getBoundingClientRect().height;
7831
7833
  this.dateRender = dateRender;
7832
7834
  var filteredDates = this.getRenderedDates(dateRender);
7833
7835
  this.getSlotDates(workDays || this.parent.activeViewOptions.workDays);
@@ -8599,8 +8601,11 @@ var TimelineEvent = /** @__PURE__ @class */ (function (_super) {
8599
8601
  this.slotCount / this.interval;
8600
8602
  for (var k = 0; k < slotCount; k++) {
8601
8603
  startDate = (k === 0) ? new Date(startDate.getTime()) : new Date(startDate.getTime() + (60000 * interval));
8604
+ if (slotCount < 1) {
8605
+ startDate = this.adjustToNearestTimeSlot(startDate, interval);
8606
+ }
8602
8607
  endDate = new Date(startDate.getTime() + (60000 * interval));
8603
- if (endDate.getTime() > endTime.getTime()) {
8608
+ if (slotCount >= 1 && endDate.getTime() > endTime.getTime()) {
8604
8609
  break;
8605
8610
  }
8606
8611
  var position_2 = this.getPosition(startDate, endDate, false, (this.day + i));
@@ -8616,6 +8621,20 @@ var TimelineEvent = /** @__PURE__ @class */ (function (_super) {
8616
8621
  }
8617
8622
  this.parent.renderTemplates();
8618
8623
  };
8624
+ TimelineEvent.prototype.adjustToNearestTimeSlot = function (inputTime, interval) {
8625
+ // Parse the input time
8626
+ var parsedTime = new Date(inputTime);
8627
+ // Get the minutes of the input time in milliseconds
8628
+ var minutesInMilliseconds = parsedTime.getHours() * 60 * 60 * 1000 + parsedTime.getMinutes() * 60 * 1000;
8629
+ // Calculate the adjusted time in milliseconds (nearest time slot)
8630
+ var adjustedMinutesInMilliseconds = Math.floor(minutesInMilliseconds / (interval * 60 * 1000)) * (interval * 60 * 1000);
8631
+ // Create a new Date object with the adjusted time
8632
+ var adjustedTime = new Date(parsedTime.getTime());
8633
+ adjustedTime.setHours(adjustedMinutesInMilliseconds / (60 * 60 * 1000) % 24);
8634
+ adjustedTime.setMinutes((adjustedMinutesInMilliseconds % (60 * 60 * 1000)) / (60 * 1000));
8635
+ // Return the adjusted time in string format
8636
+ return adjustedTime;
8637
+ };
8619
8638
  TimelineEvent.prototype.renderTimelineMoreIndicator = function (startTime, startDate, endDate, appHeight, interval, resIndex, appointmentsList, top, appLeft, appRight, cellTd, moreIndicator, appPos, position) {
8620
8639
  appLeft = (this.parent.enableRtl) ? appRight = position : position;
8621
8640
  appPos = (this.parent.enableRtl) ? appRight : appLeft;
@@ -8675,8 +8694,9 @@ var TimelineEvent = /** @__PURE__ @class */ (function (_super) {
8675
8694
  TimelineEvent.prototype.adjustAppointments = function (conWidth) {
8676
8695
  var _this = this;
8677
8696
  var tr = this.parent.element.querySelector('.' + CONTENT_TABLE_CLASS + ' tbody tr');
8678
- this.cellWidth = this.workCells[0].getBoundingClientRect().width;
8679
- var currentPercentage = (this.cellWidth * tr.children.length) / (conWidth / 100);
8697
+ var actualCellWidth = this.workCells[0].getBoundingClientRect().width;
8698
+ this.cellWidth = actualCellWidth / +(this.workCells[0].getAttribute('colspan') || 1);
8699
+ var currentPercentage = (actualCellWidth * tr.children.length) / (conWidth / 100);
8680
8700
  var apps = [].slice.call(this.parent.element.querySelectorAll('.' + APPOINTMENT_CLASS));
8681
8701
  apps.forEach(function (app) {
8682
8702
  if (_this.parent.enableRtl && app.style.right !== '0px') {
@@ -21064,7 +21084,12 @@ var Resize = /** @__PURE__ @class */ (function (_super) {
21064
21084
  var left = (this.parent.enableRtl) ? parseInt(this.actionObj.element.style.right, 10) : this.actionObj.clone.offsetLeft;
21065
21085
  if (isTimeViews) {
21066
21086
  offsetWidth = targetWidth + (Math.ceil(pageWidth / slotInterval) * slotInterval);
21067
- offsetWidth = (Math.round((left + offsetWidth) / slotInterval) * slotInterval) - left;
21087
+ if (!isLeft) {
21088
+ var roundedLeft = (+parseFloat(this.actionObj.element.style[this.parent.enableRtl ? 'right' : 'left'])).toFixed(1);
21089
+ if (roundedLeft !== left.toFixed(1)) {
21090
+ offsetWidth = (Math.round((left + offsetWidth) / slotInterval) * slotInterval) - left;
21091
+ }
21092
+ }
21068
21093
  this.actionObj.event[this.parent.eventFields.isAllDay] = false;
21069
21094
  }
21070
21095
  var width = !isLeft && ((offsetWidth + this.actionObj.clone.offsetLeft > this.scrollArgs.width)) ?
@@ -21074,9 +21099,11 @@ var Resize = /** @__PURE__ @class */ (function (_super) {
21074
21099
  -(offsetWidth - this.actionObj.cellWidth);
21075
21100
  rightValue = isTimelineView ? rightValue : isLeft ? 0 : rightValue > 0 ? 0 : rightValue;
21076
21101
  if (isTimelineView && !isLeft) {
21077
- rightValue = Math.ceil((this.actionObj.element.offsetLeft + (this.actionObj.element.getBoundingClientRect().width +
21078
- (this.actionObj.pageX - this.actionObj.X))) / slotInterval) * slotInterval;
21079
- rightValue = rightValue < 0 ? Math.abs(rightValue) : -rightValue;
21102
+ rightValue = rightValue - (Math.ceil((this.actionObj.pageX - this.actionObj.X) / slotInterval) * slotInterval);
21103
+ if (rightValue < 0) {
21104
+ rightValue = parseInt(this.actionObj.clone.style.right, 10);
21105
+ width = parseInt(this.actionObj.clone.style.width, 10);
21106
+ }
21080
21107
  }
21081
21108
  rightValue = rightValue >= this.scrollArgs.width ? this.scrollArgs.width - this.actionObj.cellWidth : rightValue;
21082
21109
  styles.right = formatUnit(rightValue);
@@ -21098,12 +21125,19 @@ var Resize = /** @__PURE__ @class */ (function (_super) {
21098
21125
  }
21099
21126
  }
21100
21127
  var leftValue = offsetLeft;
21101
- offsetLeft = isTimelineView ? isTimeViews ? isLeft ? Math.floor(offsetLeft / slotInterval) * slotInterval : offsetLeft :
21128
+ offsetLeft = isTimelineView ? isTimeViews ? isLeft ? this.actionObj.element.offsetLeft -
21129
+ (Math.ceil((this.actionObj.element.offsetLeft - offsetLeft) / slotInterval) * slotInterval) : offsetLeft :
21102
21130
  Math.floor(offsetLeft / this.actionObj.cellWidth) * this.actionObj.cellWidth :
21103
21131
  Math.ceil(Math.abs(offsetLeft) / this.actionObj.cellWidth) * this.actionObj.cellWidth;
21104
21132
  if (offsetLeft < 0) {
21105
- offsetLeft = 0;
21106
- width = this.actionObj.clone.getBoundingClientRect().width;
21133
+ if (isTimelineView && isLeft && (offsetLeft % slotInterval)) {
21134
+ offsetLeft = parseInt(this.actionObj.clone.style.left, 10);
21135
+ width = parseInt(this.actionObj.clone.style.width, 10);
21136
+ }
21137
+ else {
21138
+ offsetLeft = 0;
21139
+ width = this.actionObj.clone.getBoundingClientRect().width;
21140
+ }
21107
21141
  }
21108
21142
  var cloneWidth = Math.ceil(this.actionObj.clone.getBoundingClientRect().width / this.actionObj.cellWidth) *
21109
21143
  this.actionObj.cellWidth;
@@ -21237,7 +21271,7 @@ var YearEvent = /** @__PURE__ @class */ (function (_super) {
21237
21271
  YearEvent.prototype.timelineYearViewEvents = function () {
21238
21272
  var _this = this;
21239
21273
  var workCell = this.parent.element.querySelector('.' + WORK_CELLS_CLASS + ':not(.' + OTHERMONTH_CLASS + ')');
21240
- this.cellWidth = workCell.getBoundingClientRect().width;
21274
+ this.cellWidth = this.parent.eventBase.getCellWidth(workCell);
21241
21275
  this.cellHeader = getOuterHeight(workCell.querySelector('.' + DATE_HEADER_CLASS));
21242
21276
  var eventTable = this.parent.element.querySelector('.' + EVENT_TABLE_CLASS);
21243
21277
  this.eventHeight = getElementHeightFromClass(eventTable, APPOINTMENT_CLASS);
@@ -22824,13 +22858,20 @@ var DragAndDrop = /** @__PURE__ @class */ (function (_super) {
22824
22858
  if (this.isStepDragging) {
22825
22859
  var widthDiff = this.getWidthDiff(tr, index);
22826
22860
  if (widthDiff !== 0) {
22827
- var timeDiff = Math.round(widthDiff / this.widthPerMinute);
22861
+ var timeDiff = Math.ceil(widthDiff / this.widthPerMinute);
22828
22862
  eventStart.setMinutes(eventStart.getMinutes() + (timeDiff * this.actionObj.interval));
22829
22863
  if (this.isCursorAhead || cursorDrag) {
22830
22864
  eventStart.setMilliseconds(-(eventDuration));
22831
22865
  }
22832
22866
  else {
22833
22867
  eventStart.setMinutes(eventStart.getMinutes() - this.minDiff);
22868
+ var intervalInMS = this.actionObj.interval * MS_PER_MINUTE;
22869
+ timeDiff = Math.abs(eventStart.getTime() - this.actionObj.start.getTime()) / intervalInMS;
22870
+ var roundTimeDiff = Math.trunc(timeDiff);
22871
+ if (roundTimeDiff !== timeDiff) {
22872
+ timeDiff = (roundTimeDiff * intervalInMS) * (eventStart > this.actionObj.start ? 1 : -1);
22873
+ eventStart = new Date(this.actionObj.start.getTime() + timeDiff);
22874
+ }
22834
22875
  }
22835
22876
  }
22836
22877
  else {
@@ -22851,7 +22892,9 @@ var DragAndDrop = /** @__PURE__ @class */ (function (_super) {
22851
22892
  (this.cursorPointIndex * (this.isTimelineDayProcess ? MINUTES_PER_DAY : this.actionObj.slotInterval)));
22852
22893
  }
22853
22894
  }
22854
- eventStart = this.calculateIntervalTime(eventStart);
22895
+ if (!this.isStepDragging) {
22896
+ eventStart = this.calculateIntervalTime(eventStart);
22897
+ }
22855
22898
  if (this.isTimelineDayProcess) {
22856
22899
  var eventSrt = eventObj[this.parent.eventFields.startTime];
22857
22900
  eventStart.setHours(eventSrt.getHours(), eventSrt.getMinutes(), eventSrt.getSeconds());