Skip to content

Commit fc51172

Browse files
committed
Phase 3: Dynamic Proxy Transitioning (Windowing) #7204 starting point
1 parent 2e26e1f commit fc51172

5 files changed

Lines changed: 51 additions & 5 deletions

File tree

apps/colors/view/Viewport.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class Viewport extends BaseViewport {
4343
module: Dashboard,
4444
layout: {ntype: 'vbox', align: 'stretch'},
4545

46+
listeners: {
47+
dragBoundaryExit: 'onDragBoundaryExit'
48+
},
49+
4650
items: [{
4751
module: Panel,
4852
flex : 1,

apps/colors/view/ViewportController.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ class ViewportController extends Controller {
123123
}
124124
}
125125

126+
/**
127+
* @param {Object} data
128+
*/
129+
onDragBoundaryExit(data) {
130+
console.log('onDragBoundaryExit', data);
131+
}
132+
126133
/**
127134
* @param {Object} data
128135
*/

src/dashboard/Container.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ class Container extends BaseContainer {
4343
appName : me.appName,
4444
boundaryContainerId: me.id,
4545
owner : me,
46-
windowId : me.windowId
46+
windowId : me.windowId,
47+
listeners : {
48+
dragBoundaryExit: data => me.fire('dragBoundaryExit', data)
49+
}
4750
})
4851
})
4952
}

src/draggable/DragZone.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class DragZone extends Base {
3333
* @member {Boolean} addDragProxyCls=true
3434
*/
3535
addDragProxyCls: true,
36+
/**
37+
* Allow the drag proxy to move outside of the boundaryContainerId.
38+
* @member {Boolean} allowOverdrag=false
39+
*/
40+
allowOverdrag: false,
3641
/**
3742
* drag:move will by default only fire in case moveInMainThread === false.
3843
* In case you want to move the dragProxy inside main but still get the event,
@@ -410,7 +415,7 @@ class DragZone extends Base {
410415
return {
411416
alwaysFireDragMove : me.alwaysFireDragMove,
412417
bodyCursorStyle : me.bodyCursorStyle,
413-
boundaryContainerId: me.boundaryContainerId,
418+
boundaryContainerId: me.allowOverdrag ? null : me.boundaryContainerId,
414419
dragElementRootId : me.getDragElementRoot().id,
415420
dragProxyCls : me.dragProxyCls,
416421
dragZoneId : me.id,

src/draggable/container/SortZone.mjs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import DragZone from './DragZone.mjs';
2-
import NeoArray from '../../util/Array.mjs';
3-
import VDomUtil from '../../util/VDom.mjs';
1+
import DragZone from './DragZone.mjs';
2+
import NeoArray from '../../util/Array.mjs';
3+
import Rectangle from '../../util/Rectangle.mjs';
4+
import VDomUtil from '../../util/VDom.mjs';
45

56
/**
67
* @class Neo.draggable.container.SortZone
@@ -100,6 +101,11 @@ class SortZone extends DragZone {
100101
* @protected
101102
*/
102103
isOverDragging = false
104+
/**
105+
* @member {Boolean} isWindowDragging=false
106+
* @protected
107+
*/
108+
isWindowDragging = false
103109

104110
/**
105111
* Toggles the neo-draggable cls on items inside our owner.
@@ -207,6 +213,27 @@ class SortZone extends DragZone {
207213
return
208214
}
209215

216+
// Phase 3: Dynamic Proxy Transitioning
217+
if (this.dragProxy && !this.isWindowDragging) {
218+
const proxyRect = await this.dragProxy.getDomRect();
219+
220+
if (proxyRect) {
221+
const boundaryRect = this.boundaryContainerRect;
222+
const intersection = Rectangle.getIntersection(proxyRect, boundaryRect);
223+
const proxyArea = proxyRect.width * proxyRect.height;
224+
const intersectionArea = intersection ? intersection.width * intersection.height : 0;
225+
226+
if (proxyArea > 0 && (intersectionArea / proxyArea) < 0.5) {
227+
this.isWindowDragging = true; // Set flag to prevent re-entry
228+
229+
this.fire('dragBoundaryExit', {
230+
draggedItem: Neo.getComponent(this.dragElement.id)
231+
});
232+
return; // Stop further processing in onDragMove
233+
}
234+
}
235+
}
236+
210237
let me = this,
211238
{clientX, clientY} = data,
212239
index = me.currentIndex,

0 commit comments

Comments
 (0)