Skip to content

Commit 0fb3eb0

Browse files
committed
#7204 dragBoundaryEntry event
1 parent b415efd commit 0fb3eb0

5 files changed

Lines changed: 53 additions & 26 deletions

File tree

apps/colors/view/Viewport.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class Viewport extends BaseViewport {
4444
layout: {ntype: 'vbox', align: 'stretch'},
4545

4646
listeners: {
47-
dragBoundaryExit: 'onDragBoundaryExit'
47+
dragBoundaryEntry: 'onDragBoundaryEntry',
48+
dragBoundaryExit : 'onDragBoundaryExit'
4849
},
4950

5051
items: [{

apps/colors/view/ViewportController.mjs

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ViewportController extends Controller {
2121
* @member {Number|null} intervalId
2222
*/
2323
intervalId = null
24+
/**
25+
* @member {Boolean} #isWindowDragging=false
26+
*/
27+
#isWindowDragging = false
2428
/**
2529
* @member {Object} widgetIndexMap
2630
*/
@@ -93,8 +97,14 @@ class ViewportController extends Controller {
9397
* @param {Number} data.windowId
9498
*/
9599
async onAppDisconnect(data) {
96-
let me = this,
97-
{appName, windowId} = data,
100+
let me = this;
101+
102+
if (me.#isWindowDragging) {
103+
me.#isWindowDragging = false;
104+
return
105+
}
106+
107+
let {appName, windowId} = data,
98108
url = await Neo.Main.getByPath({path: 'document.URL', windowId}),
99109
widgetName = new URL(url).searchParams.get('name'),
100110
widget = me.getReference(widgetName);
@@ -111,25 +121,6 @@ class ViewportController extends Controller {
111121
}
112122
}
113123

114-
/**
115-
* @param {Object} data
116-
*/
117-
async onDragBoundaryExit(data) {
118-
let {draggedItem, proxyRect, sortZone} = data,
119-
widgetName = draggedItem.reference.replace('-panel', ''),
120-
popupData;
121-
122-
// Prohibit the size reduction inside #openWidgetInPopup().
123-
proxyRect.height += 50;
124-
125-
popupData = await this.#openWidgetInPopup(widgetName, proxyRect);
126-
127-
sortZone.startWindowDrag({
128-
dragData: data,
129-
...popupData
130-
});
131-
}
132-
133124
/**
134125
* @param {Object} data
135126
*/
@@ -202,6 +193,34 @@ class ViewportController extends Controller {
202193
await this.createBrowserWindow('pie-chart')
203194
}
204195

196+
/**
197+
* @param {Object} data
198+
*/
199+
onDragBoundaryEntry(data) {
200+
console.log('onDragBoundaryEntry', data)
201+
}
202+
203+
/**
204+
* @param {Object} data
205+
*/
206+
async onDragBoundaryExit(data) {
207+
let {draggedItem, proxyRect, sortZone} = data,
208+
widgetName = draggedItem.reference.replace('-panel', ''),
209+
popupData;
210+
211+
this.#isWindowDragging = true;
212+
213+
// Prohibit the size reduction inside #openWidgetInPopup().
214+
proxyRect.height += 50;
215+
216+
popupData = await this.#openWidgetInPopup(widgetName, proxyRect);
217+
218+
sortZone.startWindowDrag({
219+
dragData: data,
220+
...popupData
221+
});
222+
}
223+
205224
/**
206225
* @param {Object} data
207226
*/

src/dashboard/Container.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class Container extends BaseContainer {
4747
owner : me,
4848
windowId : me.windowId,
4949
listeners : {
50-
dragBoundaryExit: data => me.fire('dragBoundaryExit', data)
50+
dragBoundaryEntry: data => me.fire('dragBoundaryEntry', data),
51+
dragBoundaryExit : data => me.fire('dragBoundaryExit', data)
5152
}
5253
})
5354
})

src/draggable/container/SortZone.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class SortZone extends DragZone {
224224

225225
if (me.dragProxy && me.enableProxyToPopup) {
226226
const {proxyRect} = data;
227-
console.log(proxyRect);
227+
228228
if (proxyRect && me.boundaryContainerRect) {
229229
const
230230
boundaryRect = me.boundaryContainerRect,
@@ -244,7 +244,13 @@ console.log(proxyRect);
244244
return // Stop further processing in onDragMove
245245
}
246246
} else if (me.isWindowDragging) {
247-
console.log(proxyArea, intersectionArea, (intersectionArea / proxyArea) > 0.51);
247+
if (proxyArea > 0 && (intersectionArea / proxyArea) > 0.51) {
248+
me.fire('dragBoundaryEntry', {
249+
draggedItem: Neo.getComponent(me.dragElement.id),
250+
proxyRect,
251+
sortZone : me
252+
});
253+
}
248254
return;
249255
}
250256
}

src/main/addon/DragDrop.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class DragDrop extends Base {
293293
...me.getEventData(event),
294294
offsetX : me.offsetX,
295295
offsetY : me.offsetY,
296-
proxyRect: new DOMRect(x, y, me.popupWidth, me.popupHeight),
296+
proxyRect: new DOMRect(x - window.screenX, y - window.screenY, me.popupWidth, me.popupHeight),
297297
screenX : originalEvent.screenX,
298298
screenY : originalEvent.screenY,
299299
type : 'drag:move'

0 commit comments

Comments
 (0)