Skip to content

Commit 38a7406

Browse files
authored
Merge pull request #1077 from neomjs/dev
v1.3.47
2 parents 52790fe + c7270b7 commit 38a7406

File tree

4 files changed

+103
-22
lines changed

4 files changed

+103
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "neo.mjs",
3-
"version": "1.3.46",
3+
"version": "1.3.47",
44
"description": "The webworkers driven UI framework",
55
"repository": {
66
"type": "git",

src/calendar/draggable/WeekEventDragZone.mjs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class WeekEventDragZone extends DragZone {
5454
* @member {Neo.calendar.view.WeekComponent} owner=null
5555
*/
5656
owner: null,
57+
/**
58+
* @member {Number} scrollFactorLeft=3
59+
*/
60+
scrollFactorLeft: 3,
5761
/**
5862
* @member {Number} startTime=0
5963
*/
@@ -72,12 +76,15 @@ class WeekEventDragZone extends DragZone {
7276
*/
7377
afterSetProxyParentId(value, oldValue) {
7478
if (value && oldValue !== undefined) {
75-
if (this.dragProxy) {
79+
let me = this;
80+
81+
// check if the node did not get removed yet
82+
if (me.dragProxy && me.dragProxy.vdom.cn[0].id) {
7683
Neo.currentWorker.promiseMessage('main', {
7784
action: 'updateDom',
7885
deltas: [{
7986
action : 'moveNode',
80-
id : this.dragProxy.id,
87+
id : me.dragProxy.id,
8188
index : 0,
8289
parentId: value
8390
}]
@@ -154,16 +161,19 @@ class WeekEventDragZone extends DragZone {
154161
position = me.currentInterval * intervalHeight; // snap to valid intervals
155162
position = position / me.columnHeight * 100;
156163

157-
Neo.currentWorker.promiseMessage('main', {
158-
action: 'updateDom',
159-
deltas: [{
160-
id : me.dragProxy.vdom.cn[0].id,
161-
innerHTML: startTime
162-
}, {
163-
id : me.dragProxy.id,
164-
style: {top: `calc(${position}% + 1px)`}
165-
}]
166-
});
164+
// check if the node did not get removed yet
165+
if (me.dragProxy.vdom.cn[0].id) {
166+
Neo.currentWorker.promiseMessage('main', {
167+
action: 'updateDom',
168+
deltas: [{
169+
id : me.dragProxy.vdom.cn[0].id,
170+
innerHTML: startTime
171+
}, {
172+
id : me.dragProxy.id,
173+
style: {top: `calc(${position}% + 1px)`}
174+
}]
175+
});
176+
}
167177
}
168178
}
169179
}

src/draggable/DragZone.mjs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class DragZone extends Base {
6464
* @member {String|null} scrollContainerId_=null
6565
*/
6666
scrollContainerId_: null,
67+
/**
68+
* @member {Number} scrollFactorLeft_=1
69+
*/
70+
scrollFactorLeft_: 1,
71+
/**
72+
* @member {Number} scrollFactorTop_=1
73+
*/
74+
scrollFactorTop_: 1,
6775
/**
6876
* True creates a position:absolute wrapper div which contains the cloned element
6977
* @member {Boolean} useProxyWrapper=true
@@ -97,6 +105,34 @@ class DragZone extends Base {
97105
}
98106
}
99107

108+
/**
109+
* Triggered after the scrollFactorLeft config got changed
110+
* @param {Number} value
111+
* @param {Number} oldValue
112+
* @protected
113+
*/
114+
afterSetScrollFactorLeft(value, oldValue) {
115+
if (!(value === 1 && oldValue === undefined)) {
116+
Neo.main.addon.DragDrop.setScrollFactorLeft({
117+
value: value
118+
});
119+
}
120+
}
121+
122+
/**
123+
* Triggered after the scrollFactorTop config got changed
124+
* @param {Number} value
125+
* @param {Number} oldValue
126+
* @protected
127+
*/
128+
afterSetScrollFactorTop(value, oldValue) {
129+
if (!(value === 1 && oldValue === undefined)) {
130+
Neo.main.addon.DragDrop.setScrollFactorTop({
131+
value: value
132+
});
133+
}
134+
}
135+
100136
/**
101137
*
102138
* @param {Object} data
@@ -133,12 +169,17 @@ class DragZone extends Base {
133169
* Override for using custom animations
134170
*/
135171
destroyDragProxy() {
136-
Neo.currentWorker.promiseMessage('main', {
137-
action: 'updateDom',
138-
deltas: [{action: 'removeNode', id: this.dragProxy.id}]
139-
});
172+
let me = this,
173+
id = me.dragProxy.id;
174+
175+
setTimeout(() => {
176+
Neo.currentWorker.promiseMessage('main', {
177+
action: 'updateDom',
178+
deltas: [{action: 'removeNode', id: id}]
179+
});
180+
}, me.moveInMainThread ? 0 : 30);
140181

141-
this.dragProxy.destroy();
182+
me.dragProxy.destroy();
142183
}
143184

144185
/**

src/main/addon/DragDrop.mjs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class DragDrop extends Base {
5252
remote: {
5353
app: [
5454
'setDragProxyElement',
55-
'setScrollContainer'
55+
'setScrollContainer',
56+
'setScrollFactorLeft',
57+
'setScrollFactorTop'
5658
]
5759
},
5860
/**
@@ -63,6 +65,14 @@ class DragDrop extends Base {
6365
* @member {DOMRect|null} scrollContainerRect=null
6466
*/
6567
scrollContainerRect: null,
68+
/**
69+
* @member {Number} scrollFactorLeft=1
70+
*/
71+
scrollFactorLeft: 1,
72+
/**
73+
* @member {Number} scrollFactorTop=1
74+
*/
75+
scrollFactorTop: 1,
6676
/**
6777
* @member {Boolean} singleton=true
6878
* @protected
@@ -125,7 +135,9 @@ class DragDrop extends Base {
125135
initialScrollLeft : 0,
126136
initialScrollTop : 0,
127137
scrollContainerElement: null,
128-
scrollContainerRect : null
138+
scrollContainerRect : null,
139+
setScrollFactorLeft : 1,
140+
scrollFactorTop : 1
129141
});
130142

131143
DomEvents.sendMessageToApp({
@@ -202,14 +214,14 @@ class DragDrop extends Base {
202214
(deltaX < 0 && data.clientX < rect.left + gap) ||
203215
(deltaX > 0 && data.clientX > rect.right - gap)
204216
) {
205-
el.scrollLeft += (deltaX * 3); // todo: scrollFactorLeft
217+
el.scrollLeft += (deltaX * me.scrollFactorLeft);
206218
}
207219

208220
if (
209221
(deltaY < 0 && data.clientY < rect.top + gap) ||
210222
(deltaY > 0 && data.clientY > rect.bottom - gap)
211223
) {
212-
el.scrollTop += deltaY;
224+
el.scrollTop += (deltaY * me.scrollFactorTop);
213225
}
214226

215227
return {
@@ -243,6 +255,24 @@ class DragDrop extends Base {
243255
initialScrollTop : node.scrollTop,
244256
});
245257
}
258+
259+
/**
260+
*
261+
* @param {Object} data
262+
* @param {Number} data.value
263+
*/
264+
setScrollFactorLeft(data) {
265+
this.scrollFactorLeft = data.value;
266+
}
267+
268+
/**
269+
*
270+
* @param {Object} data
271+
* @param {Number} data.value
272+
*/
273+
setScrollFactorTop(data) {
274+
this.scrollFactorTop = data.value;
275+
}
246276
}
247277

248278
Neo.applyClassConfig(DragDrop);

0 commit comments

Comments
 (0)