@acorex/cdk 22.4.44 → 22.4.47

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.
@@ -565,6 +565,7 @@ class AXDragDirective {
565
565
  this.clonedElementViewRef = signal(null, /* @ts-ignore */
566
566
  ...(ngDevMode ? [{ debugName: "clonedElementViewRef" }] : /* istanbul ignore next */ []));
567
567
  this.rafId = null;
568
+ this.appliedTranslate = { x: 0, y: 0 };
568
569
  this.pendingPointerEvent = null;
569
570
  this.savedBodyCursor = null;
570
571
  this.holdDelayTimer = null;
@@ -1143,11 +1144,12 @@ class AXDragDirective {
1143
1144
  setPosition(x, y) {
1144
1145
  let constrainedX = x;
1145
1146
  let constrainedY = y;
1146
- const elementRect = this.elementRect();
1147
- const boundaryRect = this.boundaryRect();
1148
- if (boundaryRect && elementRect) {
1149
- const minX = boundaryRect.left - elementRect.left;
1150
- const minY = boundaryRect.top - elementRect.top;
1147
+ const boundaryRect = this.boundaryElement()?.getBoundingClientRect();
1148
+ if (boundaryRect) {
1149
+ // Measured on every move: the element or boundary may have been resized or re-laid out since the last drag.
1150
+ const elementRect = this.element().getBoundingClientRect();
1151
+ const minX = boundaryRect.left - (elementRect.left - this.appliedTranslate.x);
1152
+ const minY = boundaryRect.top - (elementRect.top - this.appliedTranslate.y);
1151
1153
  const maxX = minX + boundaryRect.width - elementRect.width;
1152
1154
  const maxY = minY + boundaryRect.height - elementRect.height;
1153
1155
  constrainedX = clamp(x, minX, maxX);
@@ -1159,6 +1161,7 @@ class AXDragDirective {
1159
1161
  constrainedX = this.currentAxis().x;
1160
1162
  // Direct DOM manipulation without triggering change detection
1161
1163
  this.renderer.setStyle(this.element(), 'translate', `${constrainedX}px ${constrainedY}px`);
1164
+ this.appliedTranslate = { x: constrainedX, y: constrainedY };
1162
1165
  // Only update signal and emit if position actually changed significantly (throttle)
1163
1166
  const current = this.currentAxis();
1164
1167
  if (Math.abs(current.x - constrainedX) > 0.5 || Math.abs(current.y - constrainedY) > 0.5) {