@acorex/cdk 22.1.6 → 22.1.8
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.
- package/fesm2022/acorex-cdk-drag-drop.mjs +149 -44
- package/fesm2022/acorex-cdk-drag-drop.mjs.map +1 -1
- package/fesm2022/acorex-cdk-gesture.mjs +6 -3
- package/fesm2022/acorex-cdk-gesture.mjs.map +1 -1
- package/fesm2022/acorex-cdk-horizontal-scroll.mjs +84 -41
- package/fesm2022/acorex-cdk-horizontal-scroll.mjs.map +1 -1
- package/package.json +2 -2
- package/types/acorex-cdk-drag-drop.d.ts +21 -2
- package/types/acorex-cdk-gesture.d.ts +2 -0
- package/types/acorex-cdk-horizontal-scroll.d.ts +20 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, signal, Directive, NgZone, Renderer2, ChangeDetectorRef, PLATFORM_ID, input, output, contentChildren, DOCUMENT, ViewContainerRef, contentChild,
|
|
2
|
+
import { inject, ElementRef, signal, Directive, NgZone, Renderer2, ChangeDetectorRef, PLATFORM_ID, input, output, contentChildren, linkedSignal, DOCUMENT, ViewContainerRef, contentChild, computed, effect, RendererStyleFlags2, NgModule } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import { clamp } from 'lodash-es';
|
|
5
5
|
import { NXComponent } from '@acorex/cdk/common';
|
|
@@ -72,8 +72,12 @@ class AXDropListDirective extends NXComponent {
|
|
|
72
72
|
/** The detected `gap` of the list for the current orientation. */
|
|
73
73
|
this._listGap = signal(0, /* @ts-ignore */
|
|
74
74
|
...(ngDevMode ? [{ debugName: "_listGap" }] : /* istanbul ignore next */ []));
|
|
75
|
-
/**
|
|
76
|
-
this.
|
|
75
|
+
/** Internal orientation state; can be overridden programmatically by host components. */
|
|
76
|
+
this.orientation = linkedSignal(() => this.dropListOrientation(), /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
78
|
+
/** Internal sorting-disabled state; can be overridden programmatically by host components. */
|
|
79
|
+
this.isSortingDisabled = linkedSignal(() => this.sortingDisabled(), /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "isSortingDisabled" }] : /* istanbul ignore next */ []));
|
|
77
81
|
/** DOM placeholder element for inter-list drags */
|
|
78
82
|
this._placeholderElement = null;
|
|
79
83
|
}
|
|
@@ -102,7 +106,7 @@ class AXDropListDirective extends NXComponent {
|
|
|
102
106
|
* @param dragItem The item that is being dragged.
|
|
103
107
|
*/
|
|
104
108
|
prepareSort(dragItem) {
|
|
105
|
-
if (!this.axDropList() || this.
|
|
109
|
+
if (!this.axDropList() || this.isSortingDisabled() || this._activeDragItem() || dragItem.isDragDisabled())
|
|
106
110
|
return;
|
|
107
111
|
this._activeDragItem.set(dragItem);
|
|
108
112
|
this.element.classList.add('ax-drop-list-sorting-active');
|
|
@@ -119,7 +123,7 @@ class AXDropListDirective extends NXComponent {
|
|
|
119
123
|
* @param dragItem The item entering this list.
|
|
120
124
|
*/
|
|
121
125
|
enter(dragItem) {
|
|
122
|
-
if (!this.axDropList() || this.
|
|
126
|
+
if (!this.axDropList() || this.isSortingDisabled() || this.isDragActiveForThisList(dragItem))
|
|
123
127
|
return;
|
|
124
128
|
// Clean up any existing placeholder from previous list
|
|
125
129
|
this._removePlaceholderElement();
|
|
@@ -135,10 +139,10 @@ class AXDropListDirective extends NXComponent {
|
|
|
135
139
|
sort(event, dragItem) {
|
|
136
140
|
if (!this.axDropList() ||
|
|
137
141
|
!this.isDragActiveForThisList(dragItem) ||
|
|
138
|
-
this.
|
|
142
|
+
this.isSortingDisabled() ||
|
|
139
143
|
!this._listInitialRect())
|
|
140
144
|
return;
|
|
141
|
-
const pointerPosition = this.
|
|
145
|
+
const pointerPosition = this.orientation() === 'vertical' ? event.clientY : event.clientX;
|
|
142
146
|
const newPlaceholderIndex = this._calculatePlaceholderIndex(pointerPosition);
|
|
143
147
|
if (this._placeholderIndex() !== newPlaceholderIndex) {
|
|
144
148
|
this._placeholderIndex.set(newPlaceholderIndex);
|
|
@@ -152,7 +156,7 @@ class AXDropListDirective extends NXComponent {
|
|
|
152
156
|
* @param sourceList The list where the drag originated.
|
|
153
157
|
*/
|
|
154
158
|
finalizeSort(event, droppedItem, sourceList) {
|
|
155
|
-
if (!this.axDropList() || !this.isDragActiveForThisList(droppedItem) || this.
|
|
159
|
+
if (!this.axDropList() || !this.isDragActiveForThisList(droppedItem) || this.isSortingDisabled()) {
|
|
156
160
|
this.resetSortStateAndStyles(sourceList);
|
|
157
161
|
return;
|
|
158
162
|
}
|
|
@@ -198,7 +202,9 @@ class AXDropListDirective extends NXComponent {
|
|
|
198
202
|
_cacheGeometry() {
|
|
199
203
|
this._listInitialRect.set(this.element.getBoundingClientRect());
|
|
200
204
|
this._detectAndCacheListGap();
|
|
201
|
-
const items = this._draggableItems()
|
|
205
|
+
const items = [...this._draggableItems()]
|
|
206
|
+
.sort((a, b) => a.element().compareDocumentPosition(b.element()) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1)
|
|
207
|
+
.map((itemDraggable) => {
|
|
202
208
|
const el = itemDraggable.element();
|
|
203
209
|
const style = window.getComputedStyle(el);
|
|
204
210
|
const rect = el.getBoundingClientRect();
|
|
@@ -226,7 +232,7 @@ class AXDropListDirective extends NXComponent {
|
|
|
226
232
|
const gapParts = gapValue.split(' ');
|
|
227
233
|
const rowGap = parseFloat(gapParts[0]);
|
|
228
234
|
const columnGap = parseFloat(gapParts[1] || gapParts[0]);
|
|
229
|
-
this._listGap.set(this.
|
|
235
|
+
this._listGap.set(this.orientation() === 'vertical' ? rowGap : columnGap);
|
|
230
236
|
}
|
|
231
237
|
else {
|
|
232
238
|
this._listGap.set(0);
|
|
@@ -246,15 +252,15 @@ class AXDropListDirective extends NXComponent {
|
|
|
246
252
|
const cachedItems = this._cachedItems();
|
|
247
253
|
const originalIndex = cachedItems.findIndex((d) => d.item === activeItem);
|
|
248
254
|
const siblings = cachedItems.filter((d) => d.item !== activeItem);
|
|
249
|
-
const scrollDelta = this.
|
|
255
|
+
const scrollDelta = this.orientation() === 'vertical'
|
|
250
256
|
? this.element.getBoundingClientRect().top - listRect.top
|
|
251
257
|
: this.element.getBoundingClientRect().left - listRect.left;
|
|
252
258
|
let newIndexInSiblings = -1;
|
|
253
259
|
for (let i = 0; i < siblings.length; i++) {
|
|
254
260
|
const sibling = siblings[i];
|
|
255
|
-
const itemMidPoint = (this.
|
|
261
|
+
const itemMidPoint = (this.orientation() === 'vertical' ? sibling.initialRect.top : sibling.initialRect.left) +
|
|
256
262
|
scrollDelta +
|
|
257
|
-
(this.
|
|
263
|
+
(this.orientation() === 'vertical' ? sibling.height : sibling.width) / 2;
|
|
258
264
|
if (pointerPosition < itemMidPoint) {
|
|
259
265
|
newIndexInSiblings = i;
|
|
260
266
|
break;
|
|
@@ -274,7 +280,7 @@ class AXDropListDirective extends NXComponent {
|
|
|
274
280
|
const end = Math.max(originalIndex, potentialPlaceholderIndex);
|
|
275
281
|
for (let i = start; i < end; i++) {
|
|
276
282
|
const itemData = cachedItems[i];
|
|
277
|
-
if (itemData.item !== activeItem && itemData.item.
|
|
283
|
+
if (itemData.item !== activeItem && itemData.item.isDragDisabled()) {
|
|
278
284
|
// We've hit a disabled "wall". Stop the placeholder at the boundary.
|
|
279
285
|
if (potentialPlaceholderIndex > originalIndex) {
|
|
280
286
|
return i; // Dragging down/right: stop *before* the wall.
|
|
@@ -301,17 +307,17 @@ class AXDropListDirective extends NXComponent {
|
|
|
301
307
|
else {
|
|
302
308
|
// --- INTRA-LIST DRAG: Use transforms (works well for same-list reordering) ---
|
|
303
309
|
this._removePlaceholderElement();
|
|
304
|
-
const getItemSpace = (itemData) => this.
|
|
310
|
+
const getItemSpace = (itemData) => this.orientation() === 'vertical'
|
|
305
311
|
? itemData.height + itemData.margins.top + itemData.margins.bottom
|
|
306
312
|
: itemData.width + itemData.margins.left + itemData.margins.right;
|
|
307
313
|
const draggedItemSize = isIntraListDrag ? getItemSpace(this._cachedItems()[originalIndex]) : 0;
|
|
308
314
|
this._cachedItems().forEach((data, index) => {
|
|
309
|
-
if (data.item.
|
|
315
|
+
if (data.item.isDragDisabled()) {
|
|
310
316
|
this._renderer.removeStyle(data.element, 'transform');
|
|
311
317
|
return;
|
|
312
318
|
}
|
|
313
319
|
const transform = this._calculateTransform(index, originalIndex, draggedItemSize, getItemSpace);
|
|
314
|
-
this._renderer.setStyle(data.element, 'transform', transform ? `${this.
|
|
320
|
+
this._renderer.setStyle(data.element, 'transform', transform ? `${this.orientation() === 'vertical' ? 'translateY' : 'translateX'}(${transform}px)` : '');
|
|
315
321
|
});
|
|
316
322
|
}
|
|
317
323
|
}
|
|
@@ -484,6 +490,18 @@ class AXDragDirective {
|
|
|
484
490
|
...(ngDevMode ? [undefined, { debugName: "dragBoundary" }] : /* istanbul ignore next */ []));
|
|
485
491
|
this.dragTransitionDuration = input(150, /* @ts-ignore */
|
|
486
492
|
...(ngDevMode ? [{ debugName: "dragTransitionDuration" }] : /* istanbul ignore next */ []));
|
|
493
|
+
this.isDragDisabled = linkedSignal(() => this.dragDisabled(), /* @ts-ignore */
|
|
494
|
+
...(ngDevMode ? [{ debugName: "isDragDisabled" }] : /* istanbul ignore next */ []));
|
|
495
|
+
this.lockAxis = linkedSignal(() => this.dragLockAxis(), /* @ts-ignore */
|
|
496
|
+
...(ngDevMode ? [{ debugName: "lockAxis" }] : /* istanbul ignore next */ []));
|
|
497
|
+
this.dragBoundaryOverride = linkedSignal(() => this.dragBoundary(), /* @ts-ignore */
|
|
498
|
+
...(ngDevMode ? [{ debugName: "dragBoundaryOverride" }] : /* istanbul ignore next */ []));
|
|
499
|
+
this.startDelay = linkedSignal(() => this.dragStartDelay() ?? 0, /* @ts-ignore */
|
|
500
|
+
...(ngDevMode ? [{ debugName: "startDelay" }] : /* istanbul ignore next */ []));
|
|
501
|
+
this.dragTouchAction = linkedSignal(() => 'none', /* @ts-ignore */
|
|
502
|
+
...(ngDevMode ? [{ debugName: "dragTouchAction" }] : /* istanbul ignore next */ []));
|
|
503
|
+
this.dragCursorOverride = linkedSignal(() => this.dragCursor(), /* @ts-ignore */
|
|
504
|
+
...(ngDevMode ? [{ debugName: "dragCursorOverride" }] : /* istanbul ignore next */ []));
|
|
487
505
|
this.dragPositionChanged = output();
|
|
488
506
|
this.isMoving = signal(false, /* @ts-ignore */
|
|
489
507
|
...(ngDevMode ? [{ debugName: "isMoving" }] : /* istanbul ignore next */ []));
|
|
@@ -511,19 +529,25 @@ class AXDragDirective {
|
|
|
511
529
|
...(ngDevMode ? [{ debugName: "prevDropZone" }] : /* istanbul ignore next */ []));
|
|
512
530
|
this.dragStartOffset = signal({ x: 0, y: 0 }, /* @ts-ignore */
|
|
513
531
|
...(ngDevMode ? [{ debugName: "dragStartOffset" }] : /* istanbul ignore next */ []));
|
|
532
|
+
this.pointerDownPosition = signal({ x: 0, y: 0 }, /* @ts-ignore */
|
|
533
|
+
...(ngDevMode ? [{ debugName: "pointerDownPosition" }] : /* istanbul ignore next */ []));
|
|
514
534
|
this.clonePointerOffset = signal({ x: 0, y: 0 }, /* @ts-ignore */
|
|
515
535
|
...(ngDevMode ? [{ debugName: "clonePointerOffset" }] : /* istanbul ignore next */ []));
|
|
516
536
|
this.clonedElementViewRef = signal(null, /* @ts-ignore */
|
|
517
537
|
...(ngDevMode ? [{ debugName: "clonedElementViewRef" }] : /* istanbul ignore next */ []));
|
|
518
538
|
this.rafId = null;
|
|
519
539
|
this.pendingPointerEvent = null;
|
|
540
|
+
this.savedBodyCursor = null;
|
|
541
|
+
this.holdDelayTimer = null;
|
|
542
|
+
this.holdDelayReady = signal(false, /* @ts-ignore */
|
|
543
|
+
...(ngDevMode ? [{ debugName: "holdDelayReady" }] : /* istanbul ignore next */ []));
|
|
520
544
|
this._parentDropList = inject(AXDropListDirective, { optional: true, skipSelf: true, host: false });
|
|
521
545
|
this._currentDropList = signal(null, /* @ts-ignore */
|
|
522
546
|
...(ngDevMode ? [{ debugName: "_currentDropList" }] : /* istanbul ignore next */ []));
|
|
523
547
|
this.createCloneElement = computed(() => this.dragElementClone() || !!this._parentDropList, /* @ts-ignore */
|
|
524
548
|
...(ngDevMode ? [{ debugName: "createCloneElement" }] : /* istanbul ignore next */ []));
|
|
525
549
|
this.boundaryElement = computed(() => {
|
|
526
|
-
const boundary = this.
|
|
550
|
+
const boundary = this.dragBoundaryOverride();
|
|
527
551
|
if (!boundary) {
|
|
528
552
|
return null;
|
|
529
553
|
}
|
|
@@ -556,12 +580,14 @@ class AXDragDirective {
|
|
|
556
580
|
this.listenersAttached = signal(null, /* @ts-ignore */
|
|
557
581
|
...(ngDevMode ? [{ debugName: "listenersAttached" }] : /* istanbul ignore next */ []));
|
|
558
582
|
this.#dragDisabledEffect = effect(() => {
|
|
559
|
-
if (this.
|
|
583
|
+
if (this.dragCursorOverride() === 'none') {
|
|
560
584
|
return;
|
|
561
585
|
}
|
|
562
|
-
if (!this.
|
|
563
|
-
|
|
564
|
-
|
|
586
|
+
if (!this.isDragDisabled()) {
|
|
587
|
+
if (!this.isMoving() && !this.holdDelayReady()) {
|
|
588
|
+
this.renderer.setStyle(this.handle(), 'cursor', this.dragCursorOverride());
|
|
589
|
+
}
|
|
590
|
+
this.renderer.setStyle(this.handle(), 'touch-action', this.dragTouchAction());
|
|
565
591
|
}
|
|
566
592
|
else {
|
|
567
593
|
this.renderer.removeStyle(this.handle(), 'cursor');
|
|
@@ -597,7 +623,6 @@ class AXDragDirective {
|
|
|
597
623
|
if (this._parentDropList) {
|
|
598
624
|
this.setElementTransition(this.element());
|
|
599
625
|
}
|
|
600
|
-
this.renderer.setStyle(this.element(), 'z-index', '1');
|
|
601
626
|
this.elementOpacity.set(getComputedStyle(this.element()).opacity);
|
|
602
627
|
}
|
|
603
628
|
}
|
|
@@ -615,7 +640,56 @@ class AXDragDirective {
|
|
|
615
640
|
if (this._parentDropList && this.isDragging()) {
|
|
616
641
|
this._parentDropList.cancelSort();
|
|
617
642
|
}
|
|
643
|
+
this.clearActiveDragCursor();
|
|
644
|
+
this.clearHoldDelayTimer();
|
|
645
|
+
this.renderer.removeStyle(this.element(), 'z-index');
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
resolveDropCursor(canDrop) {
|
|
649
|
+
if (this.dragCursorOverride() === 'grab') {
|
|
650
|
+
return canDrop ? 'grabbing' : 'not-allowed';
|
|
651
|
+
}
|
|
652
|
+
return canDrop ? 'move' : 'not-allowed';
|
|
653
|
+
}
|
|
654
|
+
setActiveDragCursor(cursor) {
|
|
655
|
+
if (!isPlatformBrowser(this.platformId))
|
|
656
|
+
return;
|
|
657
|
+
if (this.savedBodyCursor === null) {
|
|
658
|
+
this.savedBodyCursor = this.document.body.style.cursor;
|
|
659
|
+
}
|
|
660
|
+
this.document.body.style.cursor = cursor;
|
|
661
|
+
}
|
|
662
|
+
clearActiveDragCursor() {
|
|
663
|
+
if (!isPlatformBrowser(this.platformId) || this.savedBodyCursor === null)
|
|
664
|
+
return;
|
|
665
|
+
this.document.body.style.cursor = this.savedBodyCursor;
|
|
666
|
+
this.savedBodyCursor = null;
|
|
667
|
+
}
|
|
668
|
+
clearHoldDelayTimer() {
|
|
669
|
+
if (this.holdDelayTimer !== null) {
|
|
670
|
+
clearTimeout(this.holdDelayTimer);
|
|
671
|
+
this.holdDelayTimer = null;
|
|
672
|
+
}
|
|
673
|
+
this.holdDelayReady.set(false);
|
|
674
|
+
}
|
|
675
|
+
scheduleHoldDelayFeedback() {
|
|
676
|
+
this.clearHoldDelayTimer();
|
|
677
|
+
const delay = this.startDelay();
|
|
678
|
+
if (delay <= 0 || this.dragCursorOverride() !== 'grab') {
|
|
679
|
+
return;
|
|
618
680
|
}
|
|
681
|
+
this.holdDelayTimer = setTimeout(() => {
|
|
682
|
+
this.holdDelayTimer = null;
|
|
683
|
+
if (!this.isDragging() || this.isMoving() || this.isDragDisabled()) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.holdDelayReady.set(true);
|
|
687
|
+
this.renderer.setStyle(this.handle(), 'cursor', 'grabbing');
|
|
688
|
+
this.setActiveDragCursor('grabbing');
|
|
689
|
+
}, delay);
|
|
690
|
+
}
|
|
691
|
+
setElementDropCursor(element, cursor) {
|
|
692
|
+
this.renderer.setStyle(element, 'cursor', cursor);
|
|
619
693
|
}
|
|
620
694
|
setElementTransition(element) {
|
|
621
695
|
this.renderer.setStyle(element, 'transition-property', 'transform, opacity, translate');
|
|
@@ -628,24 +702,23 @@ class AXDragDirective {
|
|
|
628
702
|
handlePointerDown(e) {
|
|
629
703
|
if (!isPlatformBrowser(this.platformId))
|
|
630
704
|
return;
|
|
631
|
-
if (!this.axDrag() || this.
|
|
705
|
+
if (!this.axDrag() || this.isDragDisabled() || e.button !== 0 || this._parentDropList?.isSortingDisabled())
|
|
632
706
|
return;
|
|
633
707
|
this.isDragging.set(true);
|
|
634
708
|
this.movedAfterDelay.set(false);
|
|
635
|
-
if (this.
|
|
709
|
+
if (this.dragCursorOverride() === 'move') {
|
|
636
710
|
this.renderer.setStyle(this.handle(), 'cursor', 'move');
|
|
637
711
|
}
|
|
638
|
-
else if (this.dragCursor() === 'grab') {
|
|
639
|
-
this.renderer.setStyle(this.handle(), 'cursor', 'grabbing');
|
|
640
|
-
}
|
|
641
712
|
this.dragStartOffset.set({ x: e.clientX - this.currentAxis().x, y: e.clientY - this.currentAxis().y });
|
|
713
|
+
this.pointerDownPosition.set({ x: e.clientX, y: e.clientY });
|
|
642
714
|
this.renderer.setStyle(this.handle(), 'userSelect', 'none');
|
|
643
715
|
this.activePointerId.set(e.pointerId);
|
|
644
716
|
this.addDocumentListeners();
|
|
645
717
|
this.dragStartTime.set(Date.now());
|
|
718
|
+
this.scheduleHoldDelayFeedback();
|
|
646
719
|
}
|
|
647
720
|
handleDblClick() {
|
|
648
|
-
if (!this.dragResetOnDblClick() || this.
|
|
721
|
+
if (!this.dragResetOnDblClick() || this.isDragDisabled())
|
|
649
722
|
return;
|
|
650
723
|
this.setPosition(0, 0);
|
|
651
724
|
}
|
|
@@ -653,17 +726,26 @@ class AXDragDirective {
|
|
|
653
726
|
if (!this.isDragging() || !isPlatformBrowser(this.platformId) || e.pointerId !== this.activePointerId()) {
|
|
654
727
|
return;
|
|
655
728
|
}
|
|
656
|
-
e.preventDefault();
|
|
657
729
|
if (!this.isMoving()) {
|
|
658
|
-
const delay = this.
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
730
|
+
const delay = this.startDelay();
|
|
731
|
+
const down = this.pointerDownPosition();
|
|
732
|
+
const movedX = e.clientX - down.x;
|
|
733
|
+
const movedY = e.clientY - down.y;
|
|
734
|
+
const movedDistance = Math.sqrt(movedX * movedX + movedY * movedY);
|
|
735
|
+
if (delay > 0 && !this.holdDelayReady() && Date.now() - this.dragStartTime() < delay) {
|
|
736
|
+
if (movedDistance > 8) {
|
|
737
|
+
this.abortDragSequence();
|
|
738
|
+
}
|
|
739
|
+
return;
|
|
662
740
|
}
|
|
741
|
+
e.preventDefault();
|
|
663
742
|
this.isMoving.set(true);
|
|
664
743
|
this.handle().setPointerCapture(e.pointerId);
|
|
665
744
|
this.startDrag(e);
|
|
666
745
|
}
|
|
746
|
+
else {
|
|
747
|
+
e.preventDefault();
|
|
748
|
+
}
|
|
667
749
|
// Run position updates outside Angular zone for better performance
|
|
668
750
|
this.zone.runOutsideAngular(() => {
|
|
669
751
|
if (this.createCloneElement()) {
|
|
@@ -694,7 +776,24 @@ class AXDragDirective {
|
|
|
694
776
|
this.dropZoneHoverHandler(e);
|
|
695
777
|
}
|
|
696
778
|
}
|
|
779
|
+
abortDragSequence() {
|
|
780
|
+
this.clearHoldDelayTimer();
|
|
781
|
+
this.isDragging.set(false);
|
|
782
|
+
this.isMoving.set(false);
|
|
783
|
+
this.activePointerId.set(null);
|
|
784
|
+
this.removeDocumentListeners();
|
|
785
|
+
this.renderer.removeStyle(this.handle(), 'userSelect');
|
|
786
|
+
if (this.dragCursorOverride() === 'grab') {
|
|
787
|
+
this.renderer.setStyle(this.handle(), 'cursor', 'grab');
|
|
788
|
+
}
|
|
789
|
+
this.clearActiveDragCursor();
|
|
790
|
+
}
|
|
697
791
|
startDrag(e) {
|
|
792
|
+
if (this.dragCursorOverride() === 'grab') {
|
|
793
|
+
this.renderer.setStyle(this.handle(), 'cursor', 'grabbing');
|
|
794
|
+
this.setActiveDragCursor('grabbing');
|
|
795
|
+
}
|
|
796
|
+
this.renderer.setStyle(this.element(), 'z-index', '1');
|
|
698
797
|
// Add CDK-style classes
|
|
699
798
|
this.renderer.addClass(this.element(), 'ax-dragging');
|
|
700
799
|
this.renderer.addClass(this.element(), 'ax-drag-placeholder');
|
|
@@ -722,9 +821,11 @@ class AXDragDirective {
|
|
|
722
821
|
if (e.pointerId !== this.activePointerId() || !isPlatformBrowser(this.platformId) || !this.isDragging()) {
|
|
723
822
|
return;
|
|
724
823
|
}
|
|
725
|
-
|
|
824
|
+
this.clearHoldDelayTimer();
|
|
825
|
+
if (this.dragCursorOverride() === 'grab') {
|
|
726
826
|
this.renderer.setStyle(this.handle(), 'cursor', 'grab');
|
|
727
827
|
}
|
|
828
|
+
this.clearActiveDragCursor();
|
|
728
829
|
const wasMoving = this.isMoving();
|
|
729
830
|
this.isMoving.set(false);
|
|
730
831
|
this.isDragging.set(false);
|
|
@@ -738,6 +839,7 @@ class AXDragDirective {
|
|
|
738
839
|
this.renderer.removeStyle(this.handle(), 'userSelect');
|
|
739
840
|
return;
|
|
740
841
|
}
|
|
842
|
+
this.renderer.removeStyle(this.element(), 'z-index');
|
|
741
843
|
this.preventClicking();
|
|
742
844
|
const transform = this.element().style.transform;
|
|
743
845
|
let x = 0;
|
|
@@ -792,12 +894,15 @@ class AXDragDirective {
|
|
|
792
894
|
// Update cursor based on whether drop is allowed
|
|
793
895
|
if (listUnderPointer) {
|
|
794
896
|
const cloneEl = this.clonedElement();
|
|
795
|
-
const cursor = canDrop
|
|
796
|
-
if (
|
|
797
|
-
this.
|
|
897
|
+
const cursor = this.resolveDropCursor(!!canDrop);
|
|
898
|
+
if (this.dragCursorOverride() === 'grab') {
|
|
899
|
+
this.setActiveDragCursor(cursor);
|
|
900
|
+
}
|
|
901
|
+
else if (cloneEl) {
|
|
902
|
+
this.setElementDropCursor(cloneEl, cursor);
|
|
798
903
|
}
|
|
799
904
|
else {
|
|
800
|
-
this.
|
|
905
|
+
this.setElementDropCursor(this.element(), cursor);
|
|
801
906
|
}
|
|
802
907
|
}
|
|
803
908
|
if (targetList !== previousList) {
|
|
@@ -815,7 +920,7 @@ class AXDragDirective {
|
|
|
815
920
|
this._currentDropList()?.sort(e, this);
|
|
816
921
|
}
|
|
817
922
|
canDropInList(list) {
|
|
818
|
-
if (!list || list.
|
|
923
|
+
if (!list || list.isSortingDisabled() || !this._parentDropList) {
|
|
819
924
|
return false;
|
|
820
925
|
}
|
|
821
926
|
if (list === this._parentDropList) {
|
|
@@ -959,9 +1064,9 @@ class AXDragDirective {
|
|
|
959
1064
|
constrainedX = clamp(x, minX, maxX);
|
|
960
1065
|
constrainedY = clamp(y, minY, maxY);
|
|
961
1066
|
}
|
|
962
|
-
if (this.
|
|
1067
|
+
if (this.lockAxis() === 'x')
|
|
963
1068
|
constrainedY = this.currentAxis().y;
|
|
964
|
-
if (this.
|
|
1069
|
+
if (this.lockAxis() === 'y')
|
|
965
1070
|
constrainedX = this.currentAxis().x;
|
|
966
1071
|
// Direct DOM manipulation without triggering change detection
|
|
967
1072
|
this.renderer.setStyle(this.element(), 'translate', `${constrainedX}px ${constrainedY}px`);
|
|
@@ -983,9 +1088,9 @@ class AXDragDirective {
|
|
|
983
1088
|
constrainedX = clamp(x, boundaryRect.left, boundaryRect.right - cloneWidth);
|
|
984
1089
|
constrainedY = clamp(y, boundaryRect.top, boundaryRect.bottom - cloneHeight);
|
|
985
1090
|
}
|
|
986
|
-
if (this.
|
|
1091
|
+
if (this.lockAxis() === 'x')
|
|
987
1092
|
constrainedY = this.currentCloneAxis().y;
|
|
988
|
-
if (this.
|
|
1093
|
+
if (this.lockAxis() === 'y')
|
|
989
1094
|
constrainedX = this.currentCloneAxis().x;
|
|
990
1095
|
// Direct DOM manipulation without triggering change detection
|
|
991
1096
|
this.renderer.setStyle(cloneEl, 'translate', `${constrainedX}px ${constrainedY}px`);
|