Skip to content

Commit 479653b

Browse files
committed
#6378 main.addon.DragDrop: passing the boundaryContainerRect to the app worker, draggable.toolbar.SortZone: onDragMove() => added a first check if a drag OP leaves the boundary rect
1 parent c9e8a38 commit 479653b

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/draggable/DragZone.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class DragZone extends Base {
5656
* @member {String|String[]|null} boundaryContainerId=null
5757
*/
5858
boundaryContainerId: null,
59+
/**
60+
* Stores the DOMRect matching this.boundaryContainerId
61+
* @member {DOMRect|null} data=null
62+
* @protected
63+
*/
64+
boundaryContainerRect: null,
5965
/**
6066
* Store data which you want to pass to drop related events here
6167
* @member {Object|null} data=null
@@ -318,16 +324,18 @@ class DragZone extends Base {
318324
{appName, owner, windowId} = me,
319325
{cls} = owner,
320326
rect = me.getDragElementRect(data),
321-
offsetX, offsetY;
327+
mainData, offsetX, offsetY;
322328

323329
me.setData();
324330

325-
Neo.main.addon.DragDrop.setConfigs({
331+
mainData = await Neo.main.addon.DragDrop.setConfigs({
326332
appName,
327333
windowId,
328334
...me.getMainThreadConfigs()
329335
});
330336

337+
me.boundaryContainerRect = mainData.boundaryContainerRect
338+
331339
NeoArray.add(cls, 'neo-is-dragging');
332340
owner.cls = cls;
333341

src/draggable/toolbar/SortZone.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,12 @@ class SortZone extends DragZone {
180180

181181
else if (index < maxItems && (!reversed && delta > 0 || reversed && delta < 0)) {
182182
if (Math.abs(delta) > itemRects[index + 1][itemWidth] * moveFactor) {
183-
me.currentIndex++;
184-
me.switchItems(index, me.currentIndex)
183+
if (data.clientX > me.boundaryContainerRect.right) {
184+
console.log(delta, me.currentIndex, data, me.boundaryContainerRect);
185+
} else {
186+
me.currentIndex++;
187+
me.switchItems(index, me.currentIndex)
188+
}
185189
}
186190
}
187191
}

src/main/addon/DragDrop.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ class DragDrop extends Base {
445445
* @param {String|null} data.scrollContainerId
446446
* @param {Number} data.scrollFactorLeft
447447
* @param {Number} data.scrollFactorTop
448+
* @returns {Object} return the boundaryContainerRect
448449
*/
449450
setConfigs(data) {
450451
let me = this,
@@ -496,6 +497,10 @@ class DragDrop extends Base {
496497
}
497498
})
498499
}
500+
501+
return {
502+
boundaryContainerRect: me.boundaryContainerRect || null
503+
}
499504
}
500505

501506
/**

0 commit comments

Comments
 (0)