@mk-drag-and-drop/dom 0.4.1 → 0.4.2
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/README.md
CHANGED
|
@@ -369,8 +369,10 @@ Same-container sortable preview keeps its movement-responsive first-placement
|
|
|
369
369
|
behavior: forward movement places after a newly active target, backward movement
|
|
370
370
|
places before, and no sortable-axis movement uses the target midpoint. When a
|
|
371
371
|
sortable item first enters a different DOM container, the initial side is based
|
|
372
|
-
on the target midpoint on the sortable axis: above
|
|
373
|
-
before, while below or right of midpoint places
|
|
372
|
+
on the pointer position against the target midpoint on the sortable axis: above
|
|
373
|
+
or left of midpoint places before, while below or right of midpoint places
|
|
374
|
+
after. Rect-based targeting such as `centerToCenter` still selects the active
|
|
375
|
+
target; cross-container initial preview side follows the pointer.
|
|
374
376
|
|
|
375
377
|
`placementBoundary` is used after a preview placement already exists to control
|
|
376
378
|
same-target reversal and hysteresis thresholds. It does not decide the initial
|
|
@@ -53,6 +53,10 @@ export declare function getSortablePreviewPlacement(input: {
|
|
|
53
53
|
x: number;
|
|
54
54
|
y: number;
|
|
55
55
|
};
|
|
56
|
+
midpointPlacementPosition?: {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
};
|
|
56
60
|
movement: SortablePointerMovementState | null;
|
|
57
61
|
previewPlacement: SortablePreviewPlacementState | null;
|
|
58
62
|
options: NormalizedSortableOptions;
|
|
@@ -106,7 +106,9 @@ export function moveSortablePreview(input) {
|
|
|
106
106
|
if (!listElement) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const sourceListElement = input.registry.activeDrag.snapshots.get(input.draggedDraggableId)?.parent ??
|
|
110
|
+
draggedElement.parentElement;
|
|
111
|
+
const useMidpointInitialPlacement = sourceListElement !== listElement;
|
|
110
112
|
if (!target.capabilities.sortable) {
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
@@ -118,6 +120,9 @@ export function moveSortablePreview(input) {
|
|
|
118
120
|
activeDropTargetId,
|
|
119
121
|
targetElement,
|
|
120
122
|
placementPosition: input.placementPosition,
|
|
123
|
+
midpointPlacementPosition: useMidpointInitialPlacement
|
|
124
|
+
? input.pointerPosition
|
|
125
|
+
: input.placementPosition,
|
|
121
126
|
movement: input.registry.activeDrag.pointerMovement,
|
|
122
127
|
previewPlacement: input.registry.activeDrag.previewPlacement,
|
|
123
128
|
options: input.options,
|
|
@@ -155,6 +160,7 @@ export function moveSortablePreview(input) {
|
|
|
155
160
|
export function getSortablePreviewPlacement(input) {
|
|
156
161
|
const axis = input.options.axis;
|
|
157
162
|
const axisPosition = getAxisPosition(input.placementPosition, axis);
|
|
163
|
+
const midpointAxisPosition = getAxisPosition(input.midpointPlacementPosition ?? input.placementPosition, axis);
|
|
158
164
|
const targetRect = input.targetElement.getBoundingClientRect();
|
|
159
165
|
const currentDirection = getCurrentAxisMovementDirection({
|
|
160
166
|
placementPosition: input.placementPosition,
|
|
@@ -170,7 +176,7 @@ export function getSortablePreviewPlacement(input) {
|
|
|
170
176
|
placement: input.useMidpointInitialPlacement
|
|
171
177
|
? getPlacementSideFromTargetMidpoint({
|
|
172
178
|
axis,
|
|
173
|
-
axisPosition,
|
|
179
|
+
axisPosition: midpointAxisPosition,
|
|
174
180
|
targetRect,
|
|
175
181
|
})
|
|
176
182
|
: getOptimisticPlacement({
|
package/package.json
CHANGED