@fullcalendar/interaction 5.11.2 → 6.0.0-beta.1
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/main.cjs.js +809 -864
- package/main.global.js +835 -906
- package/main.global.min.js +2 -2
- package/main.js +811 -866
- package/main.js.map +1 -1
- package/package.json +3 -3
package/main.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar
|
|
2
|
+
FullCalendar v6.0.0-beta.1
|
|
3
3
|
Docs & License: https://fullcalendar.io/
|
|
4
4
|
(c) 2022 Adam Shaw
|
|
5
5
|
*/
|
|
@@ -11,9 +11,9 @@ var common = require('@fullcalendar/common');
|
|
|
11
11
|
var tslib = require('tslib');
|
|
12
12
|
|
|
13
13
|
common.config.touchMouseIgnoreWait = 500;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
let ignoreMouseDepth = 0;
|
|
15
|
+
let listenerCnt = 0;
|
|
16
|
+
let isWindowTouchMoveCancelled = false;
|
|
17
17
|
/*
|
|
18
18
|
Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
|
|
19
19
|
Tracks when the pointer "drags" on a certain element, meaning down+move+up.
|
|
@@ -27,9 +27,8 @@ emits:
|
|
|
27
27
|
- pointermove
|
|
28
28
|
- pointerup
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _this = this;
|
|
30
|
+
class PointerDragging {
|
|
31
|
+
constructor(containerEl) {
|
|
33
32
|
this.subjectEl = null;
|
|
34
33
|
// options that can be directly assigned by caller
|
|
35
34
|
this.selector = ''; // will cause subjectEl in all emitted events to be this element
|
|
@@ -42,85 +41,85 @@ var PointerDragging = /** @class */ (function () {
|
|
|
42
41
|
this.wasTouchScroll = false;
|
|
43
42
|
// Mouse
|
|
44
43
|
// ----------------------------------------------------------------------------------------------------
|
|
45
|
-
this.handleMouseDown =
|
|
46
|
-
if (!
|
|
44
|
+
this.handleMouseDown = (ev) => {
|
|
45
|
+
if (!this.shouldIgnoreMouse() &&
|
|
47
46
|
isPrimaryMouseButton(ev) &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!
|
|
53
|
-
document.addEventListener('mousemove',
|
|
47
|
+
this.tryStart(ev)) {
|
|
48
|
+
let pev = this.createEventFromMouse(ev, true);
|
|
49
|
+
this.emitter.trigger('pointerdown', pev);
|
|
50
|
+
this.initScrollWatch(pev);
|
|
51
|
+
if (!this.shouldIgnoreMove) {
|
|
52
|
+
document.addEventListener('mousemove', this.handleMouseMove);
|
|
54
53
|
}
|
|
55
|
-
document.addEventListener('mouseup',
|
|
54
|
+
document.addEventListener('mouseup', this.handleMouseUp);
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
|
-
this.handleMouseMove =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
this.handleMouseMove = (ev) => {
|
|
58
|
+
let pev = this.createEventFromMouse(ev);
|
|
59
|
+
this.recordCoords(pev);
|
|
60
|
+
this.emitter.trigger('pointermove', pev);
|
|
62
61
|
};
|
|
63
|
-
this.handleMouseUp =
|
|
64
|
-
document.removeEventListener('mousemove',
|
|
65
|
-
document.removeEventListener('mouseup',
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
this.handleMouseUp = (ev) => {
|
|
63
|
+
document.removeEventListener('mousemove', this.handleMouseMove);
|
|
64
|
+
document.removeEventListener('mouseup', this.handleMouseUp);
|
|
65
|
+
this.emitter.trigger('pointerup', this.createEventFromMouse(ev));
|
|
66
|
+
this.cleanup(); // call last so that pointerup has access to props
|
|
68
67
|
};
|
|
69
68
|
// Touch
|
|
70
69
|
// ----------------------------------------------------------------------------------------------------
|
|
71
|
-
this.handleTouchStart =
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
this.handleTouchStart = (ev) => {
|
|
71
|
+
if (this.tryStart(ev)) {
|
|
72
|
+
this.isTouchDragging = true;
|
|
73
|
+
let pev = this.createEventFromTouch(ev, true);
|
|
74
|
+
this.emitter.trigger('pointerdown', pev);
|
|
75
|
+
this.initScrollWatch(pev);
|
|
77
76
|
// unlike mouse, need to attach to target, not document
|
|
78
77
|
// https://stackoverflow.com/a/45760014
|
|
79
|
-
|
|
80
|
-
if (!
|
|
81
|
-
targetEl.addEventListener('touchmove',
|
|
78
|
+
let targetEl = ev.target;
|
|
79
|
+
if (!this.shouldIgnoreMove) {
|
|
80
|
+
targetEl.addEventListener('touchmove', this.handleTouchMove);
|
|
82
81
|
}
|
|
83
|
-
targetEl.addEventListener('touchend',
|
|
84
|
-
targetEl.addEventListener('touchcancel',
|
|
82
|
+
targetEl.addEventListener('touchend', this.handleTouchEnd);
|
|
83
|
+
targetEl.addEventListener('touchcancel', this.handleTouchEnd); // treat it as a touch end
|
|
85
84
|
// attach a handler to get called when ANY scroll action happens on the page.
|
|
86
85
|
// this was impossible to do with normal on/off because 'scroll' doesn't bubble.
|
|
87
86
|
// http://stackoverflow.com/a/32954565/96342
|
|
88
|
-
window.addEventListener('scroll',
|
|
87
|
+
window.addEventListener('scroll', this.handleTouchScroll, true);
|
|
89
88
|
}
|
|
90
89
|
};
|
|
91
|
-
this.handleTouchMove =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
this.handleTouchMove = (ev) => {
|
|
91
|
+
let pev = this.createEventFromTouch(ev);
|
|
92
|
+
this.recordCoords(pev);
|
|
93
|
+
this.emitter.trigger('pointermove', pev);
|
|
95
94
|
};
|
|
96
|
-
this.handleTouchEnd =
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
targetEl.removeEventListener('touchmove',
|
|
100
|
-
targetEl.removeEventListener('touchend',
|
|
101
|
-
targetEl.removeEventListener('touchcancel',
|
|
102
|
-
window.removeEventListener('scroll',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
this.handleTouchEnd = (ev) => {
|
|
96
|
+
if (this.isDragging) { // done to guard against touchend followed by touchcancel
|
|
97
|
+
let targetEl = ev.target;
|
|
98
|
+
targetEl.removeEventListener('touchmove', this.handleTouchMove);
|
|
99
|
+
targetEl.removeEventListener('touchend', this.handleTouchEnd);
|
|
100
|
+
targetEl.removeEventListener('touchcancel', this.handleTouchEnd);
|
|
101
|
+
window.removeEventListener('scroll', this.handleTouchScroll, true); // useCaptured=true
|
|
102
|
+
this.emitter.trigger('pointerup', this.createEventFromTouch(ev));
|
|
103
|
+
this.cleanup(); // call last so that pointerup has access to props
|
|
104
|
+
this.isTouchDragging = false;
|
|
106
105
|
startIgnoringMouse();
|
|
107
106
|
}
|
|
108
107
|
};
|
|
109
|
-
this.handleTouchScroll =
|
|
110
|
-
|
|
108
|
+
this.handleTouchScroll = () => {
|
|
109
|
+
this.wasTouchScroll = true;
|
|
111
110
|
};
|
|
112
|
-
this.handleScroll =
|
|
113
|
-
if (!
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
this.handleScroll = (ev) => {
|
|
112
|
+
if (!this.shouldIgnoreMove) {
|
|
113
|
+
let pageX = (window.pageXOffset - this.prevScrollX) + this.prevPageX;
|
|
114
|
+
let pageY = (window.pageYOffset - this.prevScrollY) + this.prevPageY;
|
|
115
|
+
this.emitter.trigger('pointermove', {
|
|
117
116
|
origEvent: ev,
|
|
118
|
-
isTouch:
|
|
119
|
-
subjectEl:
|
|
120
|
-
pageX
|
|
121
|
-
pageY
|
|
122
|
-
deltaX: pageX -
|
|
123
|
-
deltaY: pageY -
|
|
117
|
+
isTouch: this.isTouchDragging,
|
|
118
|
+
subjectEl: this.subjectEl,
|
|
119
|
+
pageX,
|
|
120
|
+
pageY,
|
|
121
|
+
deltaX: pageX - this.origPageX,
|
|
122
|
+
deltaY: pageY - this.origPageY,
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
};
|
|
@@ -130,14 +129,14 @@ var PointerDragging = /** @class */ (function () {
|
|
|
130
129
|
containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
131
130
|
listenerCreated();
|
|
132
131
|
}
|
|
133
|
-
|
|
132
|
+
destroy() {
|
|
134
133
|
this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
|
|
135
134
|
this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
136
135
|
listenerDestroyed();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
}
|
|
137
|
+
tryStart(ev) {
|
|
138
|
+
let subjectEl = this.querySubjectEl(ev);
|
|
139
|
+
let downEl = ev.target;
|
|
141
140
|
if (subjectEl &&
|
|
142
141
|
(!this.handleSelector || common.elementClosest(downEl, this.handleSelector))) {
|
|
143
142
|
this.subjectEl = subjectEl;
|
|
@@ -146,55 +145,55 @@ var PointerDragging = /** @class */ (function () {
|
|
|
146
145
|
return true;
|
|
147
146
|
}
|
|
148
147
|
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
148
|
+
}
|
|
149
|
+
cleanup() {
|
|
151
150
|
isWindowTouchMoveCancelled = false;
|
|
152
151
|
this.isDragging = false;
|
|
153
152
|
this.subjectEl = null;
|
|
154
153
|
// keep wasTouchScroll around for later access
|
|
155
154
|
this.destroyScrollWatch();
|
|
156
|
-
}
|
|
157
|
-
|
|
155
|
+
}
|
|
156
|
+
querySubjectEl(ev) {
|
|
158
157
|
if (this.selector) {
|
|
159
158
|
return common.elementClosest(ev.target, this.selector);
|
|
160
159
|
}
|
|
161
160
|
return this.containerEl;
|
|
162
|
-
}
|
|
163
|
-
|
|
161
|
+
}
|
|
162
|
+
shouldIgnoreMouse() {
|
|
164
163
|
return ignoreMouseDepth || this.isTouchDragging;
|
|
165
|
-
}
|
|
164
|
+
}
|
|
166
165
|
// can be called by user of this class, to cancel touch-based scrolling for the current drag
|
|
167
|
-
|
|
166
|
+
cancelTouchScroll() {
|
|
168
167
|
if (this.isDragging) {
|
|
169
168
|
isWindowTouchMoveCancelled = true;
|
|
170
169
|
}
|
|
171
|
-
}
|
|
170
|
+
}
|
|
172
171
|
// Scrolling that simulates pointermoves
|
|
173
172
|
// ----------------------------------------------------------------------------------------------------
|
|
174
|
-
|
|
173
|
+
initScrollWatch(ev) {
|
|
175
174
|
if (this.shouldWatchScroll) {
|
|
176
175
|
this.recordCoords(ev);
|
|
177
176
|
window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
|
|
178
177
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
178
|
+
}
|
|
179
|
+
recordCoords(ev) {
|
|
181
180
|
if (this.shouldWatchScroll) {
|
|
182
181
|
this.prevPageX = ev.pageX;
|
|
183
182
|
this.prevPageY = ev.pageY;
|
|
184
183
|
this.prevScrollX = window.pageXOffset;
|
|
185
184
|
this.prevScrollY = window.pageYOffset;
|
|
186
185
|
}
|
|
187
|
-
}
|
|
188
|
-
|
|
186
|
+
}
|
|
187
|
+
destroyScrollWatch() {
|
|
189
188
|
if (this.shouldWatchScroll) {
|
|
190
189
|
window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
|
|
191
190
|
}
|
|
192
|
-
}
|
|
191
|
+
}
|
|
193
192
|
// Event Normalization
|
|
194
193
|
// ----------------------------------------------------------------------------------------------------
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
createEventFromMouse(ev, isFirst) {
|
|
195
|
+
let deltaX = 0;
|
|
196
|
+
let deltaY = 0;
|
|
198
197
|
// TODO: repeat code
|
|
199
198
|
if (isFirst) {
|
|
200
199
|
this.origPageX = ev.pageX;
|
|
@@ -210,16 +209,16 @@ var PointerDragging = /** @class */ (function () {
|
|
|
210
209
|
subjectEl: this.subjectEl,
|
|
211
210
|
pageX: ev.pageX,
|
|
212
211
|
pageY: ev.pageY,
|
|
213
|
-
deltaX
|
|
214
|
-
deltaY
|
|
212
|
+
deltaX,
|
|
213
|
+
deltaY,
|
|
215
214
|
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
215
|
+
}
|
|
216
|
+
createEventFromTouch(ev, isFirst) {
|
|
217
|
+
let touches = ev.touches;
|
|
218
|
+
let pageX;
|
|
219
|
+
let pageY;
|
|
220
|
+
let deltaX = 0;
|
|
221
|
+
let deltaY = 0;
|
|
223
222
|
// if touch coords available, prefer,
|
|
224
223
|
// because FF would give bad ev.pageX ev.pageY
|
|
225
224
|
if (touches && touches.length) {
|
|
@@ -243,14 +242,13 @@ var PointerDragging = /** @class */ (function () {
|
|
|
243
242
|
origEvent: ev,
|
|
244
243
|
isTouch: true,
|
|
245
244
|
subjectEl: this.subjectEl,
|
|
246
|
-
pageX
|
|
247
|
-
pageY
|
|
248
|
-
deltaX
|
|
249
|
-
deltaY
|
|
245
|
+
pageX,
|
|
246
|
+
pageY,
|
|
247
|
+
deltaX,
|
|
248
|
+
deltaY,
|
|
250
249
|
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
}());
|
|
250
|
+
}
|
|
251
|
+
}
|
|
254
252
|
// Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
|
|
255
253
|
function isPrimaryMouseButton(ev) {
|
|
256
254
|
return ev.button === 0 && !ev.ctrlKey;
|
|
@@ -259,7 +257,7 @@ function isPrimaryMouseButton(ev) {
|
|
|
259
257
|
// ----------------------------------------------------------------------------------------------------
|
|
260
258
|
function startIgnoringMouse() {
|
|
261
259
|
ignoreMouseDepth += 1;
|
|
262
|
-
setTimeout(
|
|
260
|
+
setTimeout(() => {
|
|
263
261
|
ignoreMouseDepth -= 1;
|
|
264
262
|
}, common.config.touchMouseIgnoreWait);
|
|
265
263
|
}
|
|
@@ -288,8 +286,8 @@ An effect in which an element follows the movement of a pointer across the scree
|
|
|
288
286
|
The moving element is a clone of some other element.
|
|
289
287
|
Must call start + handleMove + stop.
|
|
290
288
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
class ElementMirror {
|
|
290
|
+
constructor() {
|
|
293
291
|
this.isVisible = false; // must be explicitly enabled
|
|
294
292
|
this.sourceEl = null;
|
|
295
293
|
this.mirrorEl = null;
|
|
@@ -299,7 +297,7 @@ var ElementMirror = /** @class */ (function () {
|
|
|
299
297
|
this.zIndex = 9999;
|
|
300
298
|
this.revertDuration = 0;
|
|
301
299
|
}
|
|
302
|
-
|
|
300
|
+
start(sourceEl, pageX, pageY) {
|
|
303
301
|
this.sourceEl = sourceEl;
|
|
304
302
|
this.sourceElRect = this.sourceEl.getBoundingClientRect();
|
|
305
303
|
this.origScreenX = pageX - window.pageXOffset;
|
|
@@ -307,14 +305,14 @@ var ElementMirror = /** @class */ (function () {
|
|
|
307
305
|
this.deltaX = 0;
|
|
308
306
|
this.deltaY = 0;
|
|
309
307
|
this.updateElPosition();
|
|
310
|
-
}
|
|
311
|
-
|
|
308
|
+
}
|
|
309
|
+
handleMove(pageX, pageY) {
|
|
312
310
|
this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
|
|
313
311
|
this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
|
|
314
312
|
this.updateElPosition();
|
|
315
|
-
}
|
|
313
|
+
}
|
|
316
314
|
// can be called before start
|
|
317
|
-
|
|
315
|
+
setIsVisible(bool) {
|
|
318
316
|
if (bool) {
|
|
319
317
|
if (!this.isVisible) {
|
|
320
318
|
if (this.mirrorEl) {
|
|
@@ -330,12 +328,11 @@ var ElementMirror = /** @class */ (function () {
|
|
|
330
328
|
}
|
|
331
329
|
this.isVisible = bool;
|
|
332
330
|
}
|
|
333
|
-
}
|
|
331
|
+
}
|
|
334
332
|
// always async
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
_this.cleanup();
|
|
333
|
+
stop(needsRevertAnimation, callback) {
|
|
334
|
+
let done = () => {
|
|
335
|
+
this.cleanup();
|
|
339
336
|
callback();
|
|
340
337
|
};
|
|
341
338
|
if (needsRevertAnimation &&
|
|
@@ -349,10 +346,10 @@ var ElementMirror = /** @class */ (function () {
|
|
|
349
346
|
else {
|
|
350
347
|
setTimeout(done, 0);
|
|
351
348
|
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
}
|
|
350
|
+
doRevertAnimation(callback, revertDuration) {
|
|
351
|
+
let mirrorEl = this.mirrorEl;
|
|
352
|
+
let finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
|
|
356
353
|
mirrorEl.style.transition =
|
|
357
354
|
'top ' + revertDuration + 'ms,' +
|
|
358
355
|
'left ' + revertDuration + 'ms';
|
|
@@ -360,29 +357,29 @@ var ElementMirror = /** @class */ (function () {
|
|
|
360
357
|
left: finalSourceElRect.left,
|
|
361
358
|
top: finalSourceElRect.top,
|
|
362
359
|
});
|
|
363
|
-
common.whenTransitionDone(mirrorEl,
|
|
360
|
+
common.whenTransitionDone(mirrorEl, () => {
|
|
364
361
|
mirrorEl.style.transition = '';
|
|
365
362
|
callback();
|
|
366
363
|
});
|
|
367
|
-
}
|
|
368
|
-
|
|
364
|
+
}
|
|
365
|
+
cleanup() {
|
|
369
366
|
if (this.mirrorEl) {
|
|
370
367
|
common.removeElement(this.mirrorEl);
|
|
371
368
|
this.mirrorEl = null;
|
|
372
369
|
}
|
|
373
370
|
this.sourceEl = null;
|
|
374
|
-
}
|
|
375
|
-
|
|
371
|
+
}
|
|
372
|
+
updateElPosition() {
|
|
376
373
|
if (this.sourceEl && this.isVisible) {
|
|
377
374
|
common.applyStyle(this.getMirrorEl(), {
|
|
378
375
|
left: this.sourceElRect.left + this.deltaX,
|
|
379
376
|
top: this.sourceElRect.top + this.deltaY,
|
|
380
377
|
});
|
|
381
378
|
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
379
|
+
}
|
|
380
|
+
getMirrorEl() {
|
|
381
|
+
let sourceElRect = this.sourceElRect;
|
|
382
|
+
let mirrorEl = this.mirrorEl;
|
|
386
383
|
if (!mirrorEl) {
|
|
387
384
|
mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
|
|
388
385
|
// we don't want long taps or any mouse interaction causing selection/menus.
|
|
@@ -403,9 +400,8 @@ var ElementMirror = /** @class */ (function () {
|
|
|
403
400
|
this.parentNode.appendChild(mirrorEl);
|
|
404
401
|
}
|
|
405
402
|
return mirrorEl;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
}());
|
|
403
|
+
}
|
|
404
|
+
}
|
|
409
405
|
|
|
410
406
|
/*
|
|
411
407
|
Is a cache for a given element's scroll information (all the info that ScrollController stores)
|
|
@@ -415,41 +411,39 @@ The cache can be in one of two modes:
|
|
|
415
411
|
- doesListening:false - ignores when the container is scrolled by someone else
|
|
416
412
|
- doesListening:true - watch for scrolling and update the cache
|
|
417
413
|
*/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
_this.handleScrollChange();
|
|
414
|
+
class ScrollGeomCache extends common.ScrollController {
|
|
415
|
+
constructor(scrollController, doesListening) {
|
|
416
|
+
super();
|
|
417
|
+
this.handleScroll = () => {
|
|
418
|
+
this.scrollTop = this.scrollController.getScrollTop();
|
|
419
|
+
this.scrollLeft = this.scrollController.getScrollLeft();
|
|
420
|
+
this.handleScrollChange();
|
|
426
421
|
};
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
ScrollGeomCache.prototype.destroy = function () {
|
|
422
|
+
this.scrollController = scrollController;
|
|
423
|
+
this.doesListening = doesListening;
|
|
424
|
+
this.scrollTop = this.origScrollTop = scrollController.getScrollTop();
|
|
425
|
+
this.scrollLeft = this.origScrollLeft = scrollController.getScrollLeft();
|
|
426
|
+
this.scrollWidth = scrollController.getScrollWidth();
|
|
427
|
+
this.scrollHeight = scrollController.getScrollHeight();
|
|
428
|
+
this.clientWidth = scrollController.getClientWidth();
|
|
429
|
+
this.clientHeight = scrollController.getClientHeight();
|
|
430
|
+
this.clientRect = this.computeClientRect(); // do last in case it needs cached values
|
|
431
|
+
if (this.doesListening) {
|
|
432
|
+
this.getEventTarget().addEventListener('scroll', this.handleScroll);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
destroy() {
|
|
442
436
|
if (this.doesListening) {
|
|
443
437
|
this.getEventTarget().removeEventListener('scroll', this.handleScroll);
|
|
444
438
|
}
|
|
445
|
-
}
|
|
446
|
-
|
|
439
|
+
}
|
|
440
|
+
getScrollTop() {
|
|
447
441
|
return this.scrollTop;
|
|
448
|
-
}
|
|
449
|
-
|
|
442
|
+
}
|
|
443
|
+
getScrollLeft() {
|
|
450
444
|
return this.scrollLeft;
|
|
451
|
-
}
|
|
452
|
-
|
|
445
|
+
}
|
|
446
|
+
setScrollTop(top) {
|
|
453
447
|
this.scrollController.setScrollTop(top);
|
|
454
448
|
if (!this.doesListening) {
|
|
455
449
|
// we are not relying on the element to normalize out-of-bounds scroll values
|
|
@@ -457,8 +451,8 @@ var ScrollGeomCache = /** @class */ (function (_super) {
|
|
|
457
451
|
this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
|
|
458
452
|
this.handleScrollChange();
|
|
459
453
|
}
|
|
460
|
-
}
|
|
461
|
-
|
|
454
|
+
}
|
|
455
|
+
setScrollLeft(top) {
|
|
462
456
|
this.scrollController.setScrollLeft(top);
|
|
463
457
|
if (!this.doesListening) {
|
|
464
458
|
// we are not relying on the element to normalize out-of-bounds scroll values
|
|
@@ -466,75 +460,69 @@ var ScrollGeomCache = /** @class */ (function (_super) {
|
|
|
466
460
|
this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
|
|
467
461
|
this.handleScrollChange();
|
|
468
462
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
463
|
+
}
|
|
464
|
+
getClientWidth() {
|
|
471
465
|
return this.clientWidth;
|
|
472
|
-
}
|
|
473
|
-
|
|
466
|
+
}
|
|
467
|
+
getClientHeight() {
|
|
474
468
|
return this.clientHeight;
|
|
475
|
-
}
|
|
476
|
-
|
|
469
|
+
}
|
|
470
|
+
getScrollWidth() {
|
|
477
471
|
return this.scrollWidth;
|
|
478
|
-
}
|
|
479
|
-
|
|
472
|
+
}
|
|
473
|
+
getScrollHeight() {
|
|
480
474
|
return this.scrollHeight;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
}(common.ScrollController));
|
|
475
|
+
}
|
|
476
|
+
handleScrollChange() {
|
|
477
|
+
}
|
|
478
|
+
}
|
|
486
479
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return _super.call(this, new common.ElementScrollController(el), doesListening) || this;
|
|
480
|
+
class ElementScrollGeomCache extends ScrollGeomCache {
|
|
481
|
+
constructor(el, doesListening) {
|
|
482
|
+
super(new common.ElementScrollController(el), doesListening);
|
|
491
483
|
}
|
|
492
|
-
|
|
484
|
+
getEventTarget() {
|
|
493
485
|
return this.scrollController.el;
|
|
494
|
-
}
|
|
495
|
-
|
|
486
|
+
}
|
|
487
|
+
computeClientRect() {
|
|
496
488
|
return common.computeInnerRect(this.scrollController.el);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
}(ScrollGeomCache));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
500
491
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
return _super.call(this, new common.WindowScrollController(), doesListening) || this;
|
|
492
|
+
class WindowScrollGeomCache extends ScrollGeomCache {
|
|
493
|
+
constructor(doesListening) {
|
|
494
|
+
super(new common.WindowScrollController(), doesListening);
|
|
505
495
|
}
|
|
506
|
-
|
|
496
|
+
getEventTarget() {
|
|
507
497
|
return window;
|
|
508
|
-
}
|
|
509
|
-
|
|
498
|
+
}
|
|
499
|
+
computeClientRect() {
|
|
510
500
|
return {
|
|
511
501
|
left: this.scrollLeft,
|
|
512
502
|
right: this.scrollLeft + this.clientWidth,
|
|
513
503
|
top: this.scrollTop,
|
|
514
504
|
bottom: this.scrollTop + this.clientHeight,
|
|
515
505
|
};
|
|
516
|
-
}
|
|
506
|
+
}
|
|
517
507
|
// the window is the only scroll object that changes it's rectangle relative
|
|
518
508
|
// to the document's topleft as it scrolls
|
|
519
|
-
|
|
509
|
+
handleScrollChange() {
|
|
520
510
|
this.clientRect = this.computeClientRect();
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
}(ScrollGeomCache));
|
|
511
|
+
}
|
|
512
|
+
}
|
|
524
513
|
|
|
525
514
|
// If available we are using native "performance" API instead of "Date"
|
|
526
515
|
// Read more about it on MDN:
|
|
527
516
|
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
|
|
528
|
-
|
|
517
|
+
const getTime = typeof performance === 'function' ? performance.now : Date.now;
|
|
529
518
|
/*
|
|
530
519
|
For a pointer interaction, automatically scrolls certain scroll containers when the pointer
|
|
531
520
|
approaches the edge.
|
|
532
521
|
|
|
533
522
|
The caller must call start + handleMove + stop.
|
|
534
523
|
*/
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
var _this = this;
|
|
524
|
+
class AutoScroller {
|
|
525
|
+
constructor() {
|
|
538
526
|
// options that can be set by caller
|
|
539
527
|
this.isEnabled = true;
|
|
540
528
|
this.scrollQuery = [window, '.fc-scroller'];
|
|
@@ -550,21 +538,21 @@ var AutoScroller = /** @class */ (function () {
|
|
|
550
538
|
this.everMovedDown = false;
|
|
551
539
|
this.everMovedLeft = false;
|
|
552
540
|
this.everMovedRight = false;
|
|
553
|
-
this.animate =
|
|
554
|
-
if (
|
|
555
|
-
|
|
541
|
+
this.animate = () => {
|
|
542
|
+
if (this.isAnimating) { // wasn't cancelled between animation calls
|
|
543
|
+
let edge = this.computeBestEdge(this.pointerScreenX + window.pageXOffset, this.pointerScreenY + window.pageYOffset);
|
|
556
544
|
if (edge) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
545
|
+
let now = getTime();
|
|
546
|
+
this.handleSide(edge, (now - this.msSinceRequest) / 1000);
|
|
547
|
+
this.requestAnimation(now);
|
|
560
548
|
}
|
|
561
549
|
else {
|
|
562
|
-
|
|
550
|
+
this.isAnimating = false; // will stop animation
|
|
563
551
|
}
|
|
564
552
|
}
|
|
565
553
|
};
|
|
566
554
|
}
|
|
567
|
-
|
|
555
|
+
start(pageX, pageY, scrollStartEl) {
|
|
568
556
|
if (this.isEnabled) {
|
|
569
557
|
this.scrollCaches = this.buildCaches(scrollStartEl);
|
|
570
558
|
this.pointerScreenX = null;
|
|
@@ -575,13 +563,13 @@ var AutoScroller = /** @class */ (function () {
|
|
|
575
563
|
this.everMovedRight = false;
|
|
576
564
|
this.handleMove(pageX, pageY);
|
|
577
565
|
}
|
|
578
|
-
}
|
|
579
|
-
|
|
566
|
+
}
|
|
567
|
+
handleMove(pageX, pageY) {
|
|
580
568
|
if (this.isEnabled) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
569
|
+
let pointerScreenX = pageX - window.pageXOffset;
|
|
570
|
+
let pointerScreenY = pageY - window.pageYOffset;
|
|
571
|
+
let yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
|
|
572
|
+
let xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
|
|
585
573
|
if (yDelta < 0) {
|
|
586
574
|
this.everMovedUp = true;
|
|
587
575
|
}
|
|
@@ -601,29 +589,28 @@ var AutoScroller = /** @class */ (function () {
|
|
|
601
589
|
this.requestAnimation(getTime());
|
|
602
590
|
}
|
|
603
591
|
}
|
|
604
|
-
}
|
|
605
|
-
|
|
592
|
+
}
|
|
593
|
+
stop() {
|
|
606
594
|
if (this.isEnabled) {
|
|
607
595
|
this.isAnimating = false; // will stop animation
|
|
608
|
-
for (
|
|
609
|
-
var scrollCache = _a[_i];
|
|
596
|
+
for (let scrollCache of this.scrollCaches) {
|
|
610
597
|
scrollCache.destroy();
|
|
611
598
|
}
|
|
612
599
|
this.scrollCaches = null;
|
|
613
600
|
}
|
|
614
|
-
}
|
|
615
|
-
|
|
601
|
+
}
|
|
602
|
+
requestAnimation(now) {
|
|
616
603
|
this.msSinceRequest = now;
|
|
617
604
|
requestAnimationFrame(this.animate);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
605
|
+
}
|
|
606
|
+
handleSide(edge, seconds) {
|
|
607
|
+
let { scrollCache } = edge;
|
|
608
|
+
let { edgeThreshold } = this;
|
|
609
|
+
let invDistance = edgeThreshold - edge.distance;
|
|
610
|
+
let velocity = // the closer to the edge, the faster we scroll
|
|
624
611
|
((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
|
|
625
612
|
this.maxVelocity * seconds;
|
|
626
|
-
|
|
613
|
+
let sign = 1;
|
|
627
614
|
switch (edge.name) {
|
|
628
615
|
case 'left':
|
|
629
616
|
sign = -1;
|
|
@@ -638,64 +625,61 @@ var AutoScroller = /** @class */ (function () {
|
|
|
638
625
|
scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
|
|
639
626
|
break;
|
|
640
627
|
}
|
|
641
|
-
}
|
|
628
|
+
}
|
|
642
629
|
// left/top are relative to document topleft
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
for (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
var bottomDist = rect.bottom - top;
|
|
630
|
+
computeBestEdge(left, top) {
|
|
631
|
+
let { edgeThreshold } = this;
|
|
632
|
+
let bestSide = null;
|
|
633
|
+
let scrollCaches = this.scrollCaches || [];
|
|
634
|
+
for (let scrollCache of scrollCaches) {
|
|
635
|
+
let rect = scrollCache.clientRect;
|
|
636
|
+
let leftDist = left - rect.left;
|
|
637
|
+
let rightDist = rect.right - left;
|
|
638
|
+
let topDist = top - rect.top;
|
|
639
|
+
let bottomDist = rect.bottom - top;
|
|
654
640
|
// completely within the rect?
|
|
655
641
|
if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
|
|
656
642
|
if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
|
|
657
643
|
(!bestSide || bestSide.distance > topDist)) {
|
|
658
|
-
bestSide = { scrollCache
|
|
644
|
+
bestSide = { scrollCache, name: 'top', distance: topDist };
|
|
659
645
|
}
|
|
660
646
|
if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
|
|
661
647
|
(!bestSide || bestSide.distance > bottomDist)) {
|
|
662
|
-
bestSide = { scrollCache
|
|
648
|
+
bestSide = { scrollCache, name: 'bottom', distance: bottomDist };
|
|
663
649
|
}
|
|
664
650
|
if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
|
|
665
651
|
(!bestSide || bestSide.distance > leftDist)) {
|
|
666
|
-
bestSide = { scrollCache
|
|
652
|
+
bestSide = { scrollCache, name: 'left', distance: leftDist };
|
|
667
653
|
}
|
|
668
654
|
if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
|
|
669
655
|
(!bestSide || bestSide.distance > rightDist)) {
|
|
670
|
-
bestSide = { scrollCache
|
|
656
|
+
bestSide = { scrollCache, name: 'right', distance: rightDist };
|
|
671
657
|
}
|
|
672
658
|
}
|
|
673
659
|
}
|
|
674
660
|
return bestSide;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return this.queryScrollEls(scrollStartEl).map(
|
|
661
|
+
}
|
|
662
|
+
buildCaches(scrollStartEl) {
|
|
663
|
+
return this.queryScrollEls(scrollStartEl).map((el) => {
|
|
678
664
|
if (el === window) {
|
|
679
665
|
return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
|
|
680
666
|
}
|
|
681
667
|
return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
|
|
682
668
|
});
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
for (
|
|
687
|
-
var query = _a[_i];
|
|
669
|
+
}
|
|
670
|
+
queryScrollEls(scrollStartEl) {
|
|
671
|
+
let els = [];
|
|
672
|
+
for (let query of this.scrollQuery) {
|
|
688
673
|
if (typeof query === 'object') {
|
|
689
674
|
els.push(query);
|
|
690
675
|
}
|
|
691
676
|
else {
|
|
692
|
-
els.push
|
|
677
|
+
els.push(...Array.prototype.slice.call(common.getElRoot(scrollStartEl).querySelectorAll(query)));
|
|
693
678
|
}
|
|
694
679
|
}
|
|
695
680
|
return els;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
}());
|
|
681
|
+
}
|
|
682
|
+
}
|
|
699
683
|
|
|
700
684
|
/*
|
|
701
685
|
Monitors dragging on an element. Has a number of high-level features:
|
|
@@ -703,27 +687,26 @@ Monitors dragging on an element. Has a number of high-level features:
|
|
|
703
687
|
- minimum wait time ("delay") before dragging
|
|
704
688
|
- a mirror element that follows the pointer
|
|
705
689
|
*/
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
_this.containerEl = containerEl;
|
|
690
|
+
class FeaturefulElementDragging extends common.ElementDragging {
|
|
691
|
+
constructor(containerEl, selector) {
|
|
692
|
+
super(containerEl);
|
|
693
|
+
this.containerEl = containerEl;
|
|
711
694
|
// options that can be directly set by caller
|
|
712
695
|
// the caller can also set the PointerDragging's options as well
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
if (!
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
696
|
+
this.delay = null;
|
|
697
|
+
this.minDistance = 0;
|
|
698
|
+
this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
|
|
699
|
+
this.mirrorNeedsRevert = false;
|
|
700
|
+
this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
|
|
701
|
+
this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
|
|
702
|
+
this.isDelayEnded = false;
|
|
703
|
+
this.isDistanceSurpassed = false;
|
|
704
|
+
this.delayTimeoutId = null;
|
|
705
|
+
this.onPointerDown = (ev) => {
|
|
706
|
+
if (!this.isDragging) { // so new drag doesn't happen while revert animation is going
|
|
707
|
+
this.isInteracting = true;
|
|
708
|
+
this.isDelayEnded = false;
|
|
709
|
+
this.isDistanceSurpassed = false;
|
|
727
710
|
common.preventSelection(document.body);
|
|
728
711
|
common.preventContextMenu(document.body);
|
|
729
712
|
// prevent links from being visited if there's an eventual drag.
|
|
@@ -732,95 +715,93 @@ var FeaturefulElementDragging = /** @class */ (function (_super) {
|
|
|
732
715
|
if (!ev.isTouch) {
|
|
733
716
|
ev.origEvent.preventDefault();
|
|
734
717
|
}
|
|
735
|
-
|
|
736
|
-
if (
|
|
737
|
-
!
|
|
718
|
+
this.emitter.trigger('pointerdown', ev);
|
|
719
|
+
if (this.isInteracting && // not destroyed via pointerdown handler
|
|
720
|
+
!this.pointer.shouldIgnoreMove) {
|
|
738
721
|
// actions related to initiating dragstart+dragmove+dragend...
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (!
|
|
743
|
-
|
|
722
|
+
this.mirror.setIsVisible(false); // reset. caller must set-visible
|
|
723
|
+
this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
|
|
724
|
+
this.startDelay(ev);
|
|
725
|
+
if (!this.minDistance) {
|
|
726
|
+
this.handleDistanceSurpassed(ev);
|
|
744
727
|
}
|
|
745
728
|
}
|
|
746
729
|
}
|
|
747
730
|
};
|
|
748
|
-
|
|
749
|
-
if (
|
|
750
|
-
|
|
751
|
-
if (!
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
731
|
+
this.onPointerMove = (ev) => {
|
|
732
|
+
if (this.isInteracting) {
|
|
733
|
+
this.emitter.trigger('pointermove', ev);
|
|
734
|
+
if (!this.isDistanceSurpassed) {
|
|
735
|
+
let minDistance = this.minDistance;
|
|
736
|
+
let distanceSq; // current distance from the origin, squared
|
|
737
|
+
let { deltaX, deltaY } = ev;
|
|
755
738
|
distanceSq = deltaX * deltaX + deltaY * deltaY;
|
|
756
739
|
if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
|
|
757
|
-
|
|
740
|
+
this.handleDistanceSurpassed(ev);
|
|
758
741
|
}
|
|
759
742
|
}
|
|
760
|
-
if (
|
|
743
|
+
if (this.isDragging) {
|
|
761
744
|
// a real pointer move? (not one simulated by scrolling)
|
|
762
745
|
if (ev.origEvent.type !== 'scroll') {
|
|
763
|
-
|
|
764
|
-
|
|
746
|
+
this.mirror.handleMove(ev.pageX, ev.pageY);
|
|
747
|
+
this.autoScroller.handleMove(ev.pageX, ev.pageY);
|
|
765
748
|
}
|
|
766
|
-
|
|
749
|
+
this.emitter.trigger('dragmove', ev);
|
|
767
750
|
}
|
|
768
751
|
}
|
|
769
752
|
};
|
|
770
|
-
|
|
771
|
-
if (
|
|
772
|
-
|
|
753
|
+
this.onPointerUp = (ev) => {
|
|
754
|
+
if (this.isInteracting) {
|
|
755
|
+
this.isInteracting = false;
|
|
773
756
|
common.allowSelection(document.body);
|
|
774
757
|
common.allowContextMenu(document.body);
|
|
775
|
-
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
|
|
758
|
+
this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
|
|
759
|
+
if (this.isDragging) {
|
|
760
|
+
this.autoScroller.stop();
|
|
761
|
+
this.tryStopDrag(ev); // which will stop the mirror
|
|
779
762
|
}
|
|
780
|
-
if (
|
|
781
|
-
clearTimeout(
|
|
782
|
-
|
|
763
|
+
if (this.delayTimeoutId) {
|
|
764
|
+
clearTimeout(this.delayTimeoutId);
|
|
765
|
+
this.delayTimeoutId = null;
|
|
783
766
|
}
|
|
784
767
|
}
|
|
785
768
|
};
|
|
786
|
-
|
|
787
|
-
pointer.emitter.on('pointerdown',
|
|
788
|
-
pointer.emitter.on('pointermove',
|
|
789
|
-
pointer.emitter.on('pointerup',
|
|
769
|
+
let pointer = this.pointer = new PointerDragging(containerEl);
|
|
770
|
+
pointer.emitter.on('pointerdown', this.onPointerDown);
|
|
771
|
+
pointer.emitter.on('pointermove', this.onPointerMove);
|
|
772
|
+
pointer.emitter.on('pointerup', this.onPointerUp);
|
|
790
773
|
if (selector) {
|
|
791
774
|
pointer.selector = selector;
|
|
792
775
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return _this;
|
|
776
|
+
this.mirror = new ElementMirror();
|
|
777
|
+
this.autoScroller = new AutoScroller();
|
|
796
778
|
}
|
|
797
|
-
|
|
779
|
+
destroy() {
|
|
798
780
|
this.pointer.destroy();
|
|
799
781
|
// HACK: simulate a pointer-up to end the current drag
|
|
800
782
|
// TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
|
|
801
783
|
this.onPointerUp({});
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
var _this = this;
|
|
784
|
+
}
|
|
785
|
+
startDelay(ev) {
|
|
805
786
|
if (typeof this.delay === 'number') {
|
|
806
|
-
this.delayTimeoutId = setTimeout(
|
|
807
|
-
|
|
808
|
-
|
|
787
|
+
this.delayTimeoutId = setTimeout(() => {
|
|
788
|
+
this.delayTimeoutId = null;
|
|
789
|
+
this.handleDelayEnd(ev);
|
|
809
790
|
}, this.delay); // not assignable to number!
|
|
810
791
|
}
|
|
811
792
|
else {
|
|
812
793
|
this.handleDelayEnd(ev);
|
|
813
794
|
}
|
|
814
|
-
}
|
|
815
|
-
|
|
795
|
+
}
|
|
796
|
+
handleDelayEnd(ev) {
|
|
816
797
|
this.isDelayEnded = true;
|
|
817
798
|
this.tryStartDrag(ev);
|
|
818
|
-
}
|
|
819
|
-
|
|
799
|
+
}
|
|
800
|
+
handleDistanceSurpassed(ev) {
|
|
820
801
|
this.isDistanceSurpassed = true;
|
|
821
802
|
this.tryStartDrag(ev);
|
|
822
|
-
}
|
|
823
|
-
|
|
803
|
+
}
|
|
804
|
+
tryStartDrag(ev) {
|
|
824
805
|
if (this.isDelayEnded && this.isDistanceSurpassed) {
|
|
825
806
|
if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
|
|
826
807
|
this.isDragging = true;
|
|
@@ -832,31 +813,30 @@ var FeaturefulElementDragging = /** @class */ (function (_super) {
|
|
|
832
813
|
}
|
|
833
814
|
}
|
|
834
815
|
}
|
|
835
|
-
}
|
|
836
|
-
|
|
816
|
+
}
|
|
817
|
+
tryStopDrag(ev) {
|
|
837
818
|
// .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
|
|
838
819
|
// that come from the document to fire beforehand. much more convenient this way.
|
|
839
820
|
this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
|
|
840
|
-
}
|
|
841
|
-
|
|
821
|
+
}
|
|
822
|
+
stopDrag(ev) {
|
|
842
823
|
this.isDragging = false;
|
|
843
824
|
this.emitter.trigger('dragend', ev);
|
|
844
|
-
}
|
|
825
|
+
}
|
|
845
826
|
// fill in the implementations...
|
|
846
|
-
|
|
827
|
+
setIgnoreMove(bool) {
|
|
847
828
|
this.pointer.shouldIgnoreMove = bool;
|
|
848
|
-
}
|
|
849
|
-
|
|
829
|
+
}
|
|
830
|
+
setMirrorIsVisible(bool) {
|
|
850
831
|
this.mirror.setIsVisible(bool);
|
|
851
|
-
}
|
|
852
|
-
|
|
832
|
+
}
|
|
833
|
+
setMirrorNeedsRevert(bool) {
|
|
853
834
|
this.mirrorNeedsRevert = bool;
|
|
854
|
-
}
|
|
855
|
-
|
|
835
|
+
}
|
|
836
|
+
setAutoScrollEnabled(bool) {
|
|
856
837
|
this.autoScroller.isEnabled = bool;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
}(common.ElementDragging));
|
|
838
|
+
}
|
|
839
|
+
}
|
|
860
840
|
|
|
861
841
|
/*
|
|
862
842
|
When this class is instantiated, it records the offset of an element (relative to the document topleft),
|
|
@@ -866,51 +846,46 @@ Does not access the DOM after instantiation, so highly performant.
|
|
|
866
846
|
Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
|
|
867
847
|
and an determine if a given point is inside the combined clipping rectangle.
|
|
868
848
|
*/
|
|
869
|
-
|
|
870
|
-
|
|
849
|
+
class OffsetTracker {
|
|
850
|
+
constructor(el) {
|
|
871
851
|
this.origRect = common.computeRect(el);
|
|
872
852
|
// will work fine for divs that have overflow:hidden
|
|
873
|
-
this.scrollCaches = common.getClippingParents(el).map(
|
|
853
|
+
this.scrollCaches = common.getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
|
|
874
854
|
}
|
|
875
|
-
|
|
876
|
-
for (
|
|
877
|
-
var scrollCache = _a[_i];
|
|
855
|
+
destroy() {
|
|
856
|
+
for (let scrollCache of this.scrollCaches) {
|
|
878
857
|
scrollCache.destroy();
|
|
879
858
|
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
for (
|
|
884
|
-
var scrollCache = _a[_i];
|
|
859
|
+
}
|
|
860
|
+
computeLeft() {
|
|
861
|
+
let left = this.origRect.left;
|
|
862
|
+
for (let scrollCache of this.scrollCaches) {
|
|
885
863
|
left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
|
|
886
864
|
}
|
|
887
865
|
return left;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
for (
|
|
892
|
-
var scrollCache = _a[_i];
|
|
866
|
+
}
|
|
867
|
+
computeTop() {
|
|
868
|
+
let top = this.origRect.top;
|
|
869
|
+
for (let scrollCache of this.scrollCaches) {
|
|
893
870
|
top += scrollCache.origScrollTop - scrollCache.getScrollTop();
|
|
894
871
|
}
|
|
895
872
|
return top;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
for (
|
|
900
|
-
var scrollCache = _a[_i];
|
|
873
|
+
}
|
|
874
|
+
isWithinClipping(pageX, pageY) {
|
|
875
|
+
let point = { left: pageX, top: pageY };
|
|
876
|
+
for (let scrollCache of this.scrollCaches) {
|
|
901
877
|
if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
|
|
902
878
|
!common.pointInsideRect(point, scrollCache.clientRect)) {
|
|
903
879
|
return false;
|
|
904
880
|
}
|
|
905
881
|
}
|
|
906
882
|
return true;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
}());
|
|
883
|
+
}
|
|
884
|
+
}
|
|
910
885
|
// certain clipping containers should never constrain interactions, like <html> and <body>
|
|
911
886
|
// https://github.com/fullcalendar/fullcalendar/issues/3615
|
|
912
887
|
function isIgnoredClipping(node) {
|
|
913
|
-
|
|
888
|
+
let tagName = node.tagName;
|
|
914
889
|
return tagName === 'HTML' || tagName === 'BODY';
|
|
915
890
|
}
|
|
916
891
|
|
|
@@ -927,50 +902,49 @@ emits:
|
|
|
927
902
|
- (hitchange - again, to null, if ended over a hit)
|
|
928
903
|
- dragend
|
|
929
904
|
*/
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
var _this = this;
|
|
905
|
+
class HitDragging {
|
|
906
|
+
constructor(dragging, droppableStore) {
|
|
933
907
|
// options that can be set by caller
|
|
934
908
|
this.useSubjectCenter = false;
|
|
935
909
|
this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
|
|
936
910
|
this.initialHit = null;
|
|
937
911
|
this.movingHit = null;
|
|
938
912
|
this.finalHit = null; // won't ever be populated if shouldIgnoreMove
|
|
939
|
-
this.handlePointerDown =
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
if (
|
|
913
|
+
this.handlePointerDown = (ev) => {
|
|
914
|
+
let { dragging } = this;
|
|
915
|
+
this.initialHit = null;
|
|
916
|
+
this.movingHit = null;
|
|
917
|
+
this.finalHit = null;
|
|
918
|
+
this.prepareHits();
|
|
919
|
+
this.processFirstCoord(ev);
|
|
920
|
+
if (this.initialHit || !this.requireInitial) {
|
|
947
921
|
dragging.setIgnoreMove(false);
|
|
948
922
|
// TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
|
|
949
|
-
|
|
923
|
+
this.emitter.trigger('pointerdown', ev);
|
|
950
924
|
}
|
|
951
925
|
else {
|
|
952
926
|
dragging.setIgnoreMove(true);
|
|
953
927
|
}
|
|
954
928
|
};
|
|
955
|
-
this.handleDragStart =
|
|
956
|
-
|
|
957
|
-
|
|
929
|
+
this.handleDragStart = (ev) => {
|
|
930
|
+
this.emitter.trigger('dragstart', ev);
|
|
931
|
+
this.handleMove(ev, true); // force = fire even if initially null
|
|
958
932
|
};
|
|
959
|
-
this.handleDragMove =
|
|
960
|
-
|
|
961
|
-
|
|
933
|
+
this.handleDragMove = (ev) => {
|
|
934
|
+
this.emitter.trigger('dragmove', ev);
|
|
935
|
+
this.handleMove(ev);
|
|
962
936
|
};
|
|
963
|
-
this.handlePointerUp =
|
|
964
|
-
|
|
965
|
-
|
|
937
|
+
this.handlePointerUp = (ev) => {
|
|
938
|
+
this.releaseHits();
|
|
939
|
+
this.emitter.trigger('pointerup', ev);
|
|
966
940
|
};
|
|
967
|
-
this.handleDragEnd =
|
|
968
|
-
if (
|
|
969
|
-
|
|
941
|
+
this.handleDragEnd = (ev) => {
|
|
942
|
+
if (this.movingHit) {
|
|
943
|
+
this.emitter.trigger('hitupdate', null, true, ev);
|
|
970
944
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
945
|
+
this.finalHit = this.movingHit;
|
|
946
|
+
this.movingHit = null;
|
|
947
|
+
this.emitter.trigger('dragend', ev);
|
|
974
948
|
};
|
|
975
949
|
this.droppableStore = droppableStore;
|
|
976
950
|
dragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
@@ -983,19 +957,19 @@ var HitDragging = /** @class */ (function () {
|
|
|
983
957
|
}
|
|
984
958
|
// sets initialHit
|
|
985
959
|
// sets coordAdjust
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
960
|
+
processFirstCoord(ev) {
|
|
961
|
+
let origPoint = { left: ev.pageX, top: ev.pageY };
|
|
962
|
+
let adjustedPoint = origPoint;
|
|
963
|
+
let subjectEl = ev.subjectEl;
|
|
964
|
+
let subjectRect;
|
|
991
965
|
if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
|
|
992
966
|
subjectRect = common.computeRect(subjectEl);
|
|
993
967
|
adjustedPoint = common.constrainPoint(adjustedPoint, subjectRect);
|
|
994
968
|
}
|
|
995
|
-
|
|
969
|
+
let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
|
|
996
970
|
if (initialHit) {
|
|
997
971
|
if (this.useSubjectCenter && subjectRect) {
|
|
998
|
-
|
|
972
|
+
let slicedSubjectRect = common.intersectRects(subjectRect, initialHit.rect);
|
|
999
973
|
if (slicedSubjectRect) {
|
|
1000
974
|
adjustedPoint = common.getRectCenter(slicedSubjectRect);
|
|
1001
975
|
}
|
|
@@ -1005,47 +979,47 @@ var HitDragging = /** @class */ (function () {
|
|
|
1005
979
|
else {
|
|
1006
980
|
this.coordAdjust = { left: 0, top: 0 };
|
|
1007
981
|
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
|
|
982
|
+
}
|
|
983
|
+
handleMove(ev, forceHandle) {
|
|
984
|
+
let hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
|
|
1011
985
|
if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
|
|
1012
986
|
this.movingHit = hit;
|
|
1013
987
|
this.emitter.trigger('hitupdate', hit, false, ev);
|
|
1014
988
|
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
this.offsetTrackers = common.mapHash(this.droppableStore,
|
|
989
|
+
}
|
|
990
|
+
prepareHits() {
|
|
991
|
+
this.offsetTrackers = common.mapHash(this.droppableStore, (interactionSettings) => {
|
|
1018
992
|
interactionSettings.component.prepareHits();
|
|
1019
993
|
return new OffsetTracker(interactionSettings.el);
|
|
1020
994
|
});
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
for (
|
|
995
|
+
}
|
|
996
|
+
releaseHits() {
|
|
997
|
+
let { offsetTrackers } = this;
|
|
998
|
+
for (let id in offsetTrackers) {
|
|
1025
999
|
offsetTrackers[id].destroy();
|
|
1026
1000
|
}
|
|
1027
1001
|
this.offsetTrackers = {};
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
for (
|
|
1033
|
-
|
|
1034
|
-
|
|
1002
|
+
}
|
|
1003
|
+
queryHitForOffset(offsetLeft, offsetTop) {
|
|
1004
|
+
let { droppableStore, offsetTrackers } = this;
|
|
1005
|
+
let bestHit = null;
|
|
1006
|
+
for (let id in droppableStore) {
|
|
1007
|
+
let component = droppableStore[id].component;
|
|
1008
|
+
let offsetTracker = offsetTrackers[id];
|
|
1035
1009
|
if (offsetTracker && // wasn't destroyed mid-drag
|
|
1036
1010
|
offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1011
|
+
let originLeft = offsetTracker.computeLeft();
|
|
1012
|
+
let originTop = offsetTracker.computeTop();
|
|
1013
|
+
let positionLeft = offsetLeft - originLeft;
|
|
1014
|
+
let positionTop = offsetTop - originTop;
|
|
1015
|
+
let { origRect } = offsetTracker;
|
|
1016
|
+
let width = origRect.right - origRect.left;
|
|
1017
|
+
let height = origRect.bottom - origRect.top;
|
|
1044
1018
|
if (
|
|
1045
1019
|
// must be within the element's bounds
|
|
1046
1020
|
positionLeft >= 0 && positionLeft < width &&
|
|
1047
1021
|
positionTop >= 0 && positionTop < height) {
|
|
1048
|
-
|
|
1022
|
+
let hit = component.queryHit(positionLeft, positionTop, width, height);
|
|
1049
1023
|
if (hit && (
|
|
1050
1024
|
// make sure the hit is within activeRange, meaning it's not a dead cell
|
|
1051
1025
|
common.rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
|
|
@@ -1063,9 +1037,8 @@ var HitDragging = /** @class */ (function () {
|
|
|
1063
1037
|
}
|
|
1064
1038
|
}
|
|
1065
1039
|
return bestHit;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
}());
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1069
1042
|
function isHitsEqual(hit0, hit1) {
|
|
1070
1043
|
if (!hit0 && !hit1) {
|
|
1071
1044
|
return true;
|
|
@@ -1077,9 +1050,8 @@ function isHitsEqual(hit0, hit1) {
|
|
|
1077
1050
|
}
|
|
1078
1051
|
|
|
1079
1052
|
function buildDatePointApiWithContext(dateSpan, context) {
|
|
1080
|
-
|
|
1081
|
-
for (
|
|
1082
|
-
var transform = _a[_i];
|
|
1053
|
+
let props = {};
|
|
1054
|
+
for (let transform of context.pluginHooks.datePointTransforms) {
|
|
1083
1055
|
tslib.__assign(props, transform(dateSpan, context));
|
|
1084
1056
|
}
|
|
1085
1057
|
tslib.__assign(props, buildDatePointApi(dateSpan, context.dateEnv));
|
|
@@ -1097,74 +1069,70 @@ function buildDatePointApi(span, dateEnv) {
|
|
|
1097
1069
|
Monitors when the user clicks on a specific date/time of a component.
|
|
1098
1070
|
A pointerdown+pointerup on the same "hit" constitutes a click.
|
|
1099
1071
|
*/
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
var downEl = pev.origEvent.target;
|
|
1072
|
+
class DateClicking extends common.Interaction {
|
|
1073
|
+
constructor(settings) {
|
|
1074
|
+
super(settings);
|
|
1075
|
+
this.handlePointerDown = (pev) => {
|
|
1076
|
+
let { dragging } = this;
|
|
1077
|
+
let downEl = pev.origEvent.target;
|
|
1107
1078
|
// do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
|
|
1108
|
-
dragging.setIgnoreMove(!
|
|
1079
|
+
dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
|
|
1109
1080
|
};
|
|
1110
1081
|
// won't even fire if moving was ignored
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1082
|
+
this.handleDragEnd = (ev) => {
|
|
1083
|
+
let { component } = this;
|
|
1084
|
+
let { pointer } = this.dragging;
|
|
1114
1085
|
if (!pointer.wasTouchScroll) {
|
|
1115
|
-
|
|
1086
|
+
let { initialHit, finalHit } = this.hitDragging;
|
|
1116
1087
|
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1088
|
+
let { context } = component;
|
|
1089
|
+
let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
|
|
1119
1090
|
context.emitter.trigger('dateClick', arg);
|
|
1120
1091
|
}
|
|
1121
1092
|
}
|
|
1122
1093
|
};
|
|
1123
1094
|
// we DO want to watch pointer moves because otherwise finalHit won't get populated
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
hitDragging.emitter.on('pointerdown',
|
|
1128
|
-
hitDragging.emitter.on('dragend',
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
DateClicking.prototype.destroy = function () {
|
|
1095
|
+
this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1096
|
+
this.dragging.autoScroller.isEnabled = false;
|
|
1097
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, common.interactionSettingsToStore(settings));
|
|
1098
|
+
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1099
|
+
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1100
|
+
}
|
|
1101
|
+
destroy() {
|
|
1132
1102
|
this.dragging.destroy();
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
}(common.Interaction));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1136
1105
|
|
|
1137
1106
|
/*
|
|
1138
1107
|
Tracks when the user selects a portion of time of a component,
|
|
1139
1108
|
constituted by a drag over date cells, with a possible delay at the beginning of the drag.
|
|
1140
1109
|
*/
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
var canSelect = options.selectable &&
|
|
1110
|
+
class DateSelecting extends common.Interaction {
|
|
1111
|
+
constructor(settings) {
|
|
1112
|
+
super(settings);
|
|
1113
|
+
this.dragSelection = null;
|
|
1114
|
+
this.handlePointerDown = (ev) => {
|
|
1115
|
+
let { component, dragging } = this;
|
|
1116
|
+
let { options } = component.context;
|
|
1117
|
+
let canSelect = options.selectable &&
|
|
1150
1118
|
component.isValidDateDownEl(ev.origEvent.target);
|
|
1151
1119
|
// don't bother to watch expensive moves if component won't do selection
|
|
1152
1120
|
dragging.setIgnoreMove(!canSelect);
|
|
1153
1121
|
// if touch, require user to hold down
|
|
1154
1122
|
dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
|
|
1155
1123
|
};
|
|
1156
|
-
|
|
1157
|
-
|
|
1124
|
+
this.handleDragStart = (ev) => {
|
|
1125
|
+
this.component.context.calendarApi.unselect(ev); // unselect previous selections
|
|
1158
1126
|
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1127
|
+
this.handleHitUpdate = (hit, isFinal) => {
|
|
1128
|
+
let { context } = this.component;
|
|
1129
|
+
let dragSelection = null;
|
|
1130
|
+
let isInvalid = false;
|
|
1163
1131
|
if (hit) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
&&
|
|
1167
|
-
&& !
|
|
1132
|
+
let initialHit = this.hitDragging.initialHit;
|
|
1133
|
+
let disallowed = hit.componentId === initialHit.componentId
|
|
1134
|
+
&& this.isHitComboAllowed
|
|
1135
|
+
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1168
1136
|
if (!disallowed) {
|
|
1169
1137
|
dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
|
|
1170
1138
|
}
|
|
@@ -1186,56 +1154,53 @@ var DateSelecting = /** @class */ (function (_super) {
|
|
|
1186
1154
|
common.disableCursor();
|
|
1187
1155
|
}
|
|
1188
1156
|
if (!isFinal) {
|
|
1189
|
-
|
|
1157
|
+
this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
|
|
1190
1158
|
}
|
|
1191
1159
|
};
|
|
1192
|
-
|
|
1193
|
-
if (
|
|
1160
|
+
this.handlePointerUp = (pev) => {
|
|
1161
|
+
if (this.dragSelection) {
|
|
1194
1162
|
// selection is already rendered, so just need to report selection
|
|
1195
|
-
common.triggerDateSelect(
|
|
1196
|
-
|
|
1163
|
+
common.triggerDateSelect(this.dragSelection, pev, this.component.context);
|
|
1164
|
+
this.dragSelection = null;
|
|
1197
1165
|
}
|
|
1198
1166
|
};
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1167
|
+
let { component } = settings;
|
|
1168
|
+
let { options } = component.context;
|
|
1169
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1202
1170
|
dragging.touchScrollAllowed = false;
|
|
1203
1171
|
dragging.minDistance = options.selectMinDistance || 0;
|
|
1204
1172
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1205
|
-
|
|
1206
|
-
hitDragging.emitter.on('pointerdown',
|
|
1207
|
-
hitDragging.emitter.on('dragstart',
|
|
1208
|
-
hitDragging.emitter.on('hitupdate',
|
|
1209
|
-
hitDragging.emitter.on('pointerup',
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
DateSelecting.prototype.destroy = function () {
|
|
1173
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, common.interactionSettingsToStore(settings));
|
|
1174
|
+
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1175
|
+
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1176
|
+
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
1177
|
+
hitDragging.emitter.on('pointerup', this.handlePointerUp);
|
|
1178
|
+
}
|
|
1179
|
+
destroy() {
|
|
1213
1180
|
this.dragging.destroy();
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
}(common.Interaction));
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1217
1183
|
function getComponentTouchDelay$1(component) {
|
|
1218
|
-
|
|
1219
|
-
|
|
1184
|
+
let { options } = component.context;
|
|
1185
|
+
let delay = options.selectLongPressDelay;
|
|
1220
1186
|
if (delay == null) {
|
|
1221
1187
|
delay = options.longPressDelay;
|
|
1222
1188
|
}
|
|
1223
1189
|
return delay;
|
|
1224
1190
|
}
|
|
1225
1191
|
function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1192
|
+
let dateSpan0 = hit0.dateSpan;
|
|
1193
|
+
let dateSpan1 = hit1.dateSpan;
|
|
1194
|
+
let ms = [
|
|
1229
1195
|
dateSpan0.range.start,
|
|
1230
1196
|
dateSpan0.range.end,
|
|
1231
1197
|
dateSpan1.range.start,
|
|
1232
1198
|
dateSpan1.range.end,
|
|
1233
1199
|
];
|
|
1234
1200
|
ms.sort(common.compareNumbers);
|
|
1235
|
-
|
|
1236
|
-
for (
|
|
1237
|
-
|
|
1238
|
-
var res = transformer(hit0, hit1);
|
|
1201
|
+
let props = {};
|
|
1202
|
+
for (let transformer of dateSelectionTransformers) {
|
|
1203
|
+
let res = transformer(hit0, hit1);
|
|
1239
1204
|
if (res === false) {
|
|
1240
1205
|
return null;
|
|
1241
1206
|
}
|
|
@@ -1248,30 +1213,29 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1248
1213
|
return props;
|
|
1249
1214
|
}
|
|
1250
1215
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
var _this = _super.call(this, settings) || this;
|
|
1216
|
+
class EventDragging extends common.Interaction {
|
|
1217
|
+
constructor(settings) {
|
|
1218
|
+
super(settings);
|
|
1255
1219
|
// internal state
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1220
|
+
this.subjectEl = null;
|
|
1221
|
+
this.subjectSeg = null; // the seg being selected/dragged
|
|
1222
|
+
this.isDragging = false;
|
|
1223
|
+
this.eventRange = null;
|
|
1224
|
+
this.relevantEvents = null; // the events being dragged
|
|
1225
|
+
this.receivingContext = null;
|
|
1226
|
+
this.validMutation = null;
|
|
1227
|
+
this.mutatedRelevantEvents = null;
|
|
1228
|
+
this.handlePointerDown = (ev) => {
|
|
1229
|
+
let origTarget = ev.origEvent.target;
|
|
1230
|
+
let { component, dragging } = this;
|
|
1231
|
+
let { mirror } = dragging;
|
|
1232
|
+
let { options } = component.context;
|
|
1233
|
+
let initialContext = component.context;
|
|
1234
|
+
this.subjectEl = ev.subjectEl;
|
|
1235
|
+
let subjectSeg = this.subjectSeg = common.getElSeg(ev.subjectEl);
|
|
1236
|
+
let eventRange = this.eventRange = subjectSeg.eventRange;
|
|
1237
|
+
let eventInstanceId = eventRange.instance.instanceId;
|
|
1238
|
+
this.relevantEvents = common.getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
|
|
1275
1239
|
dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
|
|
1276
1240
|
dragging.delay =
|
|
1277
1241
|
// only do a touch delay if touch and this event hasn't been selected yet
|
|
@@ -1285,58 +1249,58 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1285
1249
|
mirror.parentNode = common.elementClosest(origTarget, '.fc');
|
|
1286
1250
|
}
|
|
1287
1251
|
mirror.revertDuration = options.dragRevertDuration;
|
|
1288
|
-
|
|
1252
|
+
let isValid = component.isValidSegDownEl(origTarget) &&
|
|
1289
1253
|
!common.elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
|
|
1290
1254
|
dragging.setIgnoreMove(!isValid);
|
|
1291
1255
|
// disable dragging for elements that are resizable (ie, selectable)
|
|
1292
1256
|
// but are not draggable
|
|
1293
|
-
|
|
1257
|
+
this.isDragging = isValid &&
|
|
1294
1258
|
ev.subjectEl.classList.contains('fc-event-draggable');
|
|
1295
1259
|
};
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1260
|
+
this.handleDragStart = (ev) => {
|
|
1261
|
+
let initialContext = this.component.context;
|
|
1262
|
+
let eventRange = this.eventRange;
|
|
1263
|
+
let eventInstanceId = eventRange.instance.instanceId;
|
|
1300
1264
|
if (ev.isTouch) {
|
|
1301
1265
|
// need to select a different event?
|
|
1302
|
-
if (eventInstanceId !==
|
|
1303
|
-
initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId
|
|
1266
|
+
if (eventInstanceId !== this.component.props.eventSelection) {
|
|
1267
|
+
initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId });
|
|
1304
1268
|
}
|
|
1305
1269
|
}
|
|
1306
1270
|
else {
|
|
1307
1271
|
// if now using mouse, but was previous touch interaction, clear selected event
|
|
1308
1272
|
initialContext.dispatch({ type: 'UNSELECT_EVENT' });
|
|
1309
1273
|
}
|
|
1310
|
-
if (
|
|
1274
|
+
if (this.isDragging) {
|
|
1311
1275
|
initialContext.calendarApi.unselect(ev); // unselect *date* selection
|
|
1312
1276
|
initialContext.emitter.trigger('eventDragStart', {
|
|
1313
|
-
el:
|
|
1277
|
+
el: this.subjectEl,
|
|
1314
1278
|
event: new common.EventApi(initialContext, eventRange.def, eventRange.instance),
|
|
1315
1279
|
jsEvent: ev.origEvent,
|
|
1316
1280
|
view: initialContext.viewApi,
|
|
1317
1281
|
});
|
|
1318
1282
|
}
|
|
1319
1283
|
};
|
|
1320
|
-
|
|
1321
|
-
if (!
|
|
1284
|
+
this.handleHitUpdate = (hit, isFinal) => {
|
|
1285
|
+
if (!this.isDragging) {
|
|
1322
1286
|
return;
|
|
1323
1287
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1288
|
+
let relevantEvents = this.relevantEvents;
|
|
1289
|
+
let initialHit = this.hitDragging.initialHit;
|
|
1290
|
+
let initialContext = this.component.context;
|
|
1327
1291
|
// states based on new hit
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1292
|
+
let receivingContext = null;
|
|
1293
|
+
let mutation = null;
|
|
1294
|
+
let mutatedRelevantEvents = null;
|
|
1295
|
+
let isInvalid = false;
|
|
1296
|
+
let interaction = {
|
|
1333
1297
|
affectedEvents: relevantEvents,
|
|
1334
1298
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1335
1299
|
isEvent: true,
|
|
1336
1300
|
};
|
|
1337
1301
|
if (hit) {
|
|
1338
1302
|
receivingContext = hit.context;
|
|
1339
|
-
|
|
1303
|
+
let receivingOptions = receivingContext.options;
|
|
1340
1304
|
if (initialContext === receivingContext ||
|
|
1341
1305
|
(receivingOptions.editable && receivingOptions.droppable)) {
|
|
1342
1306
|
mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
|
|
@@ -1355,7 +1319,7 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1355
1319
|
receivingContext = null;
|
|
1356
1320
|
}
|
|
1357
1321
|
}
|
|
1358
|
-
|
|
1322
|
+
this.displayDrag(receivingContext, interaction);
|
|
1359
1323
|
if (!isInvalid) {
|
|
1360
1324
|
common.enableCursor();
|
|
1361
1325
|
}
|
|
@@ -1367,140 +1331,138 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1367
1331
|
isHitsEqual(initialHit, hit)) {
|
|
1368
1332
|
mutation = null;
|
|
1369
1333
|
}
|
|
1370
|
-
|
|
1334
|
+
this.dragging.setMirrorNeedsRevert(!mutation);
|
|
1371
1335
|
// render the mirror if no already-rendered mirror
|
|
1372
1336
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1373
|
-
|
|
1337
|
+
this.dragging.setMirrorIsVisible(!hit || !common.getElRoot(this.subjectEl).querySelector('.fc-event-mirror'));
|
|
1374
1338
|
// assign states based on new hit
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1339
|
+
this.receivingContext = receivingContext;
|
|
1340
|
+
this.validMutation = mutation;
|
|
1341
|
+
this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
1378
1342
|
}
|
|
1379
1343
|
};
|
|
1380
|
-
|
|
1381
|
-
if (!
|
|
1382
|
-
|
|
1344
|
+
this.handlePointerUp = () => {
|
|
1345
|
+
if (!this.isDragging) {
|
|
1346
|
+
this.cleanup(); // because handleDragEnd won't fire
|
|
1383
1347
|
}
|
|
1384
1348
|
};
|
|
1385
|
-
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
el:
|
|
1349
|
+
this.handleDragEnd = (ev) => {
|
|
1350
|
+
if (this.isDragging) {
|
|
1351
|
+
let initialContext = this.component.context;
|
|
1352
|
+
let initialView = initialContext.viewApi;
|
|
1353
|
+
let { receivingContext, validMutation } = this;
|
|
1354
|
+
let eventDef = this.eventRange.def;
|
|
1355
|
+
let eventInstance = this.eventRange.instance;
|
|
1356
|
+
let eventApi = new common.EventApi(initialContext, eventDef, eventInstance);
|
|
1357
|
+
let relevantEvents = this.relevantEvents;
|
|
1358
|
+
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1359
|
+
let { finalHit } = this.hitDragging;
|
|
1360
|
+
this.clearDrag(); // must happen after revert animation
|
|
1361
|
+
initialContext.emitter.trigger('eventDragStop', {
|
|
1362
|
+
el: this.subjectEl,
|
|
1399
1363
|
event: eventApi,
|
|
1400
1364
|
jsEvent: ev.origEvent,
|
|
1401
1365
|
view: initialView,
|
|
1402
1366
|
});
|
|
1403
1367
|
if (validMutation) {
|
|
1404
1368
|
// dropped within same calendar
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
1407
|
-
|
|
1369
|
+
if (receivingContext === initialContext) {
|
|
1370
|
+
let updatedEventApi = new common.EventApi(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1371
|
+
initialContext.dispatch({
|
|
1408
1372
|
type: 'MERGE_EVENTS',
|
|
1409
|
-
eventStore:
|
|
1373
|
+
eventStore: mutatedRelevantEvents,
|
|
1410
1374
|
});
|
|
1411
|
-
|
|
1375
|
+
let eventChangeArg = {
|
|
1412
1376
|
oldEvent: eventApi,
|
|
1413
1377
|
event: updatedEventApi,
|
|
1414
|
-
relatedEvents: common.buildEventApis(
|
|
1415
|
-
revert
|
|
1416
|
-
|
|
1378
|
+
relatedEvents: common.buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
|
|
1379
|
+
revert() {
|
|
1380
|
+
initialContext.dispatch({
|
|
1417
1381
|
type: 'MERGE_EVENTS',
|
|
1418
|
-
eventStore:
|
|
1382
|
+
eventStore: relevantEvents, // the pre-change data
|
|
1419
1383
|
});
|
|
1420
1384
|
},
|
|
1421
1385
|
};
|
|
1422
|
-
|
|
1423
|
-
for (
|
|
1424
|
-
|
|
1425
|
-
tslib.__assign(transformed, transformer(validMutation, initialContext_1));
|
|
1386
|
+
let transformed = {};
|
|
1387
|
+
for (let transformer of initialContext.getCurrentData().pluginHooks.eventDropTransformers) {
|
|
1388
|
+
tslib.__assign(transformed, transformer(validMutation, initialContext));
|
|
1426
1389
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1390
|
+
initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
|
|
1391
|
+
initialContext.emitter.trigger('eventChange', eventChangeArg);
|
|
1429
1392
|
// dropped in different calendar
|
|
1430
1393
|
}
|
|
1431
|
-
else if (
|
|
1432
|
-
|
|
1394
|
+
else if (receivingContext) {
|
|
1395
|
+
let eventRemoveArg = {
|
|
1433
1396
|
event: eventApi,
|
|
1434
|
-
relatedEvents: common.buildEventApis(
|
|
1435
|
-
revert
|
|
1436
|
-
|
|
1397
|
+
relatedEvents: common.buildEventApis(relevantEvents, initialContext, eventInstance),
|
|
1398
|
+
revert() {
|
|
1399
|
+
initialContext.dispatch({
|
|
1437
1400
|
type: 'MERGE_EVENTS',
|
|
1438
|
-
eventStore:
|
|
1401
|
+
eventStore: relevantEvents,
|
|
1439
1402
|
});
|
|
1440
1403
|
},
|
|
1441
1404
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1405
|
+
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
|
|
1406
|
+
initialContext.dispatch({
|
|
1444
1407
|
type: 'REMOVE_EVENTS',
|
|
1445
|
-
eventStore:
|
|
1408
|
+
eventStore: relevantEvents,
|
|
1446
1409
|
});
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1410
|
+
initialContext.emitter.trigger('eventRemove', eventRemoveArg);
|
|
1411
|
+
let addedEventDef = mutatedRelevantEvents.defs[eventDef.defId];
|
|
1412
|
+
let addedEventInstance = mutatedRelevantEvents.instances[eventInstance.instanceId];
|
|
1413
|
+
let addedEventApi = new common.EventApi(receivingContext, addedEventDef, addedEventInstance);
|
|
1414
|
+
receivingContext.dispatch({
|
|
1452
1415
|
type: 'MERGE_EVENTS',
|
|
1453
|
-
eventStore:
|
|
1416
|
+
eventStore: mutatedRelevantEvents,
|
|
1454
1417
|
});
|
|
1455
|
-
|
|
1418
|
+
let eventAddArg = {
|
|
1456
1419
|
event: addedEventApi,
|
|
1457
|
-
relatedEvents: common.buildEventApis(
|
|
1458
|
-
revert
|
|
1459
|
-
|
|
1420
|
+
relatedEvents: common.buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
|
|
1421
|
+
revert() {
|
|
1422
|
+
receivingContext.dispatch({
|
|
1460
1423
|
type: 'REMOVE_EVENTS',
|
|
1461
|
-
eventStore:
|
|
1424
|
+
eventStore: mutatedRelevantEvents,
|
|
1462
1425
|
});
|
|
1463
1426
|
},
|
|
1464
1427
|
};
|
|
1465
|
-
|
|
1428
|
+
receivingContext.emitter.trigger('eventAdd', eventAddArg);
|
|
1466
1429
|
if (ev.isTouch) {
|
|
1467
|
-
|
|
1430
|
+
receivingContext.dispatch({
|
|
1468
1431
|
type: 'SELECT_EVENT',
|
|
1469
1432
|
eventInstanceId: eventInstance.instanceId,
|
|
1470
1433
|
});
|
|
1471
1434
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1435
|
+
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
|
|
1436
|
+
receivingContext.emitter.trigger('eventReceive', Object.assign(Object.assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
|
|
1474
1437
|
}
|
|
1475
1438
|
}
|
|
1476
1439
|
else {
|
|
1477
|
-
|
|
1440
|
+
initialContext.emitter.trigger('_noEventDrop');
|
|
1478
1441
|
}
|
|
1479
1442
|
}
|
|
1480
|
-
|
|
1443
|
+
this.cleanup();
|
|
1481
1444
|
};
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1445
|
+
let { component } = this;
|
|
1446
|
+
let { options } = component.context;
|
|
1447
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1485
1448
|
dragging.pointer.selector = EventDragging.SELECTOR;
|
|
1486
1449
|
dragging.touchScrollAllowed = false;
|
|
1487
1450
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1488
|
-
|
|
1451
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, common.interactionSettingsStore);
|
|
1489
1452
|
hitDragging.useSubjectCenter = settings.useEventCenter;
|
|
1490
|
-
hitDragging.emitter.on('pointerdown',
|
|
1491
|
-
hitDragging.emitter.on('dragstart',
|
|
1492
|
-
hitDragging.emitter.on('hitupdate',
|
|
1493
|
-
hitDragging.emitter.on('pointerup',
|
|
1494
|
-
hitDragging.emitter.on('dragend',
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
EventDragging.prototype.destroy = function () {
|
|
1453
|
+
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1454
|
+
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1455
|
+
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
1456
|
+
hitDragging.emitter.on('pointerup', this.handlePointerUp);
|
|
1457
|
+
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1458
|
+
}
|
|
1459
|
+
destroy() {
|
|
1498
1460
|
this.dragging.destroy();
|
|
1499
|
-
}
|
|
1461
|
+
}
|
|
1500
1462
|
// render a drag state on the next receivingCalendar
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1463
|
+
displayDrag(nextContext, state) {
|
|
1464
|
+
let initialContext = this.component.context;
|
|
1465
|
+
let prevContext = this.receivingContext;
|
|
1504
1466
|
// does the previous calendar need to be cleared?
|
|
1505
1467
|
if (prevContext && prevContext !== nextContext) {
|
|
1506
1468
|
// does the initial calendar need to be cleared?
|
|
@@ -1521,12 +1483,12 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1521
1483
|
}
|
|
1522
1484
|
}
|
|
1523
1485
|
if (nextContext) {
|
|
1524
|
-
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state
|
|
1486
|
+
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
|
|
1525
1487
|
}
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1488
|
+
}
|
|
1489
|
+
clearDrag() {
|
|
1490
|
+
let initialCalendar = this.component.context;
|
|
1491
|
+
let { receivingContext } = this;
|
|
1530
1492
|
if (receivingContext) {
|
|
1531
1493
|
receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1532
1494
|
}
|
|
@@ -1534,8 +1496,8 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1534
1496
|
if (initialCalendar !== receivingContext) {
|
|
1535
1497
|
initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1536
1498
|
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1499
|
+
}
|
|
1500
|
+
cleanup() {
|
|
1539
1501
|
this.subjectSeg = null;
|
|
1540
1502
|
this.isDragging = false;
|
|
1541
1503
|
this.eventRange = null;
|
|
@@ -1543,18 +1505,17 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1543
1505
|
this.receivingContext = null;
|
|
1544
1506
|
this.validMutation = null;
|
|
1545
1507
|
this.mutatedRelevantEvents = null;
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
}(common.Interaction));
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
// TODO: test this in IE11
|
|
1511
|
+
// QUESTION: why do we need it on the resizable???
|
|
1512
|
+
EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
|
|
1552
1513
|
function computeEventMutation(hit0, hit1, massagers) {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1514
|
+
let dateSpan0 = hit0.dateSpan;
|
|
1515
|
+
let dateSpan1 = hit1.dateSpan;
|
|
1516
|
+
let date0 = dateSpan0.range.start;
|
|
1517
|
+
let date1 = dateSpan1.range.start;
|
|
1518
|
+
let standardProps = {};
|
|
1558
1519
|
if (dateSpan0.allDay !== dateSpan1.allDay) {
|
|
1559
1520
|
standardProps.allDay = dateSpan1.allDay;
|
|
1560
1521
|
standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
|
|
@@ -1564,59 +1525,57 @@ function computeEventMutation(hit0, hit1, massagers) {
|
|
|
1564
1525
|
date0 = common.startOfDay(date0);
|
|
1565
1526
|
}
|
|
1566
1527
|
}
|
|
1567
|
-
|
|
1528
|
+
let delta = common.diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
|
|
1568
1529
|
hit0.largeUnit :
|
|
1569
1530
|
null);
|
|
1570
1531
|
if (delta.milliseconds) { // has hours/minutes/seconds
|
|
1571
1532
|
standardProps.allDay = false;
|
|
1572
1533
|
}
|
|
1573
|
-
|
|
1534
|
+
let mutation = {
|
|
1574
1535
|
datesDelta: delta,
|
|
1575
|
-
standardProps
|
|
1536
|
+
standardProps,
|
|
1576
1537
|
};
|
|
1577
|
-
for (
|
|
1578
|
-
var massager = massagers_1[_i];
|
|
1538
|
+
for (let massager of massagers) {
|
|
1579
1539
|
massager(mutation, hit0, hit1);
|
|
1580
1540
|
}
|
|
1581
1541
|
return mutation;
|
|
1582
1542
|
}
|
|
1583
1543
|
function getComponentTouchDelay(component) {
|
|
1584
|
-
|
|
1585
|
-
|
|
1544
|
+
let { options } = component.context;
|
|
1545
|
+
let delay = options.eventLongPressDelay;
|
|
1586
1546
|
if (delay == null) {
|
|
1587
1547
|
delay = options.longPressDelay;
|
|
1588
1548
|
}
|
|
1589
1549
|
return delay;
|
|
1590
1550
|
}
|
|
1591
1551
|
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
var _this = _super.call(this, settings) || this;
|
|
1552
|
+
class EventResizing extends common.Interaction {
|
|
1553
|
+
constructor(settings) {
|
|
1554
|
+
super(settings);
|
|
1596
1555
|
// internal state
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1556
|
+
this.draggingSegEl = null;
|
|
1557
|
+
this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
|
|
1558
|
+
this.eventRange = null;
|
|
1559
|
+
this.relevantEvents = null;
|
|
1560
|
+
this.validMutation = null;
|
|
1561
|
+
this.mutatedRelevantEvents = null;
|
|
1562
|
+
this.handlePointerDown = (ev) => {
|
|
1563
|
+
let { component } = this;
|
|
1564
|
+
let segEl = this.querySegEl(ev);
|
|
1565
|
+
let seg = common.getElSeg(segEl);
|
|
1566
|
+
let eventRange = this.eventRange = seg.eventRange;
|
|
1567
|
+
this.dragging.minDistance = component.context.options.eventDragMinDistance;
|
|
1609
1568
|
// if touch, need to be working with a selected event
|
|
1610
|
-
|
|
1611
|
-
(ev.isTouch &&
|
|
1569
|
+
this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
|
|
1570
|
+
(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
|
|
1612
1571
|
};
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1572
|
+
this.handleDragStart = (ev) => {
|
|
1573
|
+
let { context } = this.component;
|
|
1574
|
+
let eventRange = this.eventRange;
|
|
1575
|
+
this.relevantEvents = common.getRelevantEvents(context.getCurrentData().eventStore, this.eventRange.instance.instanceId);
|
|
1576
|
+
let segEl = this.querySegEl(ev);
|
|
1577
|
+
this.draggingSegEl = segEl;
|
|
1578
|
+
this.draggingSeg = common.getElSeg(segEl);
|
|
1620
1579
|
context.calendarApi.unselect();
|
|
1621
1580
|
context.emitter.trigger('eventResizeStart', {
|
|
1622
1581
|
el: segEl,
|
|
@@ -1625,23 +1584,23 @@ var EventResizing = /** @class */ (function (_super) {
|
|
|
1625
1584
|
view: context.viewApi,
|
|
1626
1585
|
});
|
|
1627
1586
|
};
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1587
|
+
this.handleHitUpdate = (hit, isFinal, ev) => {
|
|
1588
|
+
let { context } = this.component;
|
|
1589
|
+
let relevantEvents = this.relevantEvents;
|
|
1590
|
+
let initialHit = this.hitDragging.initialHit;
|
|
1591
|
+
let eventInstance = this.eventRange.instance;
|
|
1592
|
+
let mutation = null;
|
|
1593
|
+
let mutatedRelevantEvents = null;
|
|
1594
|
+
let isInvalid = false;
|
|
1595
|
+
let interaction = {
|
|
1637
1596
|
affectedEvents: relevantEvents,
|
|
1638
1597
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1639
1598
|
isEvent: true,
|
|
1640
1599
|
};
|
|
1641
1600
|
if (hit) {
|
|
1642
|
-
|
|
1643
|
-
&&
|
|
1644
|
-
&& !
|
|
1601
|
+
let disallowed = hit.componentId === initialHit.componentId
|
|
1602
|
+
&& this.isHitComboAllowed
|
|
1603
|
+
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1645
1604
|
if (!disallowed) {
|
|
1646
1605
|
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
|
|
1647
1606
|
}
|
|
@@ -1675,77 +1634,75 @@ var EventResizing = /** @class */ (function (_super) {
|
|
|
1675
1634
|
if (mutation && isHitsEqual(initialHit, hit)) {
|
|
1676
1635
|
mutation = null;
|
|
1677
1636
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1637
|
+
this.validMutation = mutation;
|
|
1638
|
+
this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
1680
1639
|
}
|
|
1681
1640
|
};
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1641
|
+
this.handleDragEnd = (ev) => {
|
|
1642
|
+
let { context } = this.component;
|
|
1643
|
+
let eventDef = this.eventRange.def;
|
|
1644
|
+
let eventInstance = this.eventRange.instance;
|
|
1645
|
+
let eventApi = new common.EventApi(context, eventDef, eventInstance);
|
|
1646
|
+
let relevantEvents = this.relevantEvents;
|
|
1647
|
+
let mutatedRelevantEvents = this.mutatedRelevantEvents;
|
|
1689
1648
|
context.emitter.trigger('eventResizeStop', {
|
|
1690
|
-
el:
|
|
1649
|
+
el: this.draggingSegEl,
|
|
1691
1650
|
event: eventApi,
|
|
1692
1651
|
jsEvent: ev.origEvent,
|
|
1693
1652
|
view: context.viewApi,
|
|
1694
1653
|
});
|
|
1695
|
-
if (
|
|
1696
|
-
|
|
1654
|
+
if (this.validMutation) {
|
|
1655
|
+
let updatedEventApi = new common.EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1697
1656
|
context.dispatch({
|
|
1698
1657
|
type: 'MERGE_EVENTS',
|
|
1699
1658
|
eventStore: mutatedRelevantEvents,
|
|
1700
1659
|
});
|
|
1701
|
-
|
|
1660
|
+
let eventChangeArg = {
|
|
1702
1661
|
oldEvent: eventApi,
|
|
1703
1662
|
event: updatedEventApi,
|
|
1704
1663
|
relatedEvents: common.buildEventApis(mutatedRelevantEvents, context, eventInstance),
|
|
1705
|
-
revert
|
|
1664
|
+
revert() {
|
|
1706
1665
|
context.dispatch({
|
|
1707
1666
|
type: 'MERGE_EVENTS',
|
|
1708
1667
|
eventStore: relevantEvents, // the pre-change events
|
|
1709
1668
|
});
|
|
1710
1669
|
},
|
|
1711
1670
|
};
|
|
1712
|
-
context.emitter.trigger('eventResize',
|
|
1671
|
+
context.emitter.trigger('eventResize', Object.assign(Object.assign({}, eventChangeArg), { el: this.draggingSegEl, startDelta: this.validMutation.startDelta || common.createDuration(0), endDelta: this.validMutation.endDelta || common.createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
|
|
1713
1672
|
context.emitter.trigger('eventChange', eventChangeArg);
|
|
1714
1673
|
}
|
|
1715
1674
|
else {
|
|
1716
1675
|
context.emitter.trigger('_noEventResize');
|
|
1717
1676
|
}
|
|
1718
1677
|
// reset all internal state
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1678
|
+
this.draggingSeg = null;
|
|
1679
|
+
this.relevantEvents = null;
|
|
1680
|
+
this.validMutation = null;
|
|
1722
1681
|
// okay to keep eventInstance around. useful to set it in handlePointerDown
|
|
1723
1682
|
};
|
|
1724
|
-
|
|
1725
|
-
|
|
1683
|
+
let { component } = settings;
|
|
1684
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1726
1685
|
dragging.pointer.selector = '.fc-event-resizer';
|
|
1727
1686
|
dragging.touchScrollAllowed = false;
|
|
1728
1687
|
dragging.autoScroller.isEnabled = component.context.options.dragScroll;
|
|
1729
|
-
|
|
1730
|
-
hitDragging.emitter.on('pointerdown',
|
|
1731
|
-
hitDragging.emitter.on('dragstart',
|
|
1732
|
-
hitDragging.emitter.on('hitupdate',
|
|
1733
|
-
hitDragging.emitter.on('dragend',
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
EventResizing.prototype.destroy = function () {
|
|
1688
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, common.interactionSettingsToStore(settings));
|
|
1689
|
+
hitDragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
1690
|
+
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1691
|
+
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
1692
|
+
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1693
|
+
}
|
|
1694
|
+
destroy() {
|
|
1737
1695
|
this.dragging.destroy();
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1696
|
+
}
|
|
1697
|
+
querySegEl(ev) {
|
|
1740
1698
|
return common.elementClosest(ev.subjectEl, '.fc-event');
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
}(common.Interaction));
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1744
1701
|
function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1702
|
+
let dateEnv = hit0.context.dateEnv;
|
|
1703
|
+
let date0 = hit0.dateSpan.range.start;
|
|
1704
|
+
let date1 = hit1.dateSpan.range.start;
|
|
1705
|
+
let delta = common.diffDates(date0, date1, dateEnv, hit0.largeUnit);
|
|
1749
1706
|
if (isFromStart) {
|
|
1750
1707
|
if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
|
|
1751
1708
|
return { startDelta: delta };
|
|
@@ -1757,47 +1714,46 @@ function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
|
1757
1714
|
return null;
|
|
1758
1715
|
}
|
|
1759
1716
|
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
var _this = this;
|
|
1717
|
+
class UnselectAuto {
|
|
1718
|
+
constructor(context) {
|
|
1763
1719
|
this.context = context;
|
|
1764
1720
|
this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
|
|
1765
1721
|
this.matchesCancel = false;
|
|
1766
1722
|
this.matchesEvent = false;
|
|
1767
|
-
this.onSelect =
|
|
1723
|
+
this.onSelect = (selectInfo) => {
|
|
1768
1724
|
if (selectInfo.jsEvent) {
|
|
1769
|
-
|
|
1725
|
+
this.isRecentPointerDateSelect = true;
|
|
1770
1726
|
}
|
|
1771
1727
|
};
|
|
1772
|
-
this.onDocumentPointerDown =
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1728
|
+
this.onDocumentPointerDown = (pev) => {
|
|
1729
|
+
let unselectCancel = this.context.options.unselectCancel;
|
|
1730
|
+
let downEl = common.getEventTargetViaRoot(pev.origEvent);
|
|
1731
|
+
this.matchesCancel = !!common.elementClosest(downEl, unselectCancel);
|
|
1732
|
+
this.matchesEvent = !!common.elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
|
|
1777
1733
|
};
|
|
1778
|
-
this.onDocumentPointerUp =
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1734
|
+
this.onDocumentPointerUp = (pev) => {
|
|
1735
|
+
let { context } = this;
|
|
1736
|
+
let { documentPointer } = this;
|
|
1737
|
+
let calendarState = context.getCurrentData();
|
|
1782
1738
|
// touch-scrolling should never unfocus any type of selection
|
|
1783
1739
|
if (!documentPointer.wasTouchScroll) {
|
|
1784
1740
|
if (calendarState.dateSelection && // an existing date selection?
|
|
1785
|
-
!
|
|
1741
|
+
!this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
|
|
1786
1742
|
) {
|
|
1787
|
-
|
|
1788
|
-
if (unselectAuto && (!unselectAuto || !
|
|
1743
|
+
let unselectAuto = context.options.unselectAuto;
|
|
1744
|
+
if (unselectAuto && (!unselectAuto || !this.matchesCancel)) {
|
|
1789
1745
|
context.calendarApi.unselect(pev);
|
|
1790
1746
|
}
|
|
1791
1747
|
}
|
|
1792
1748
|
if (calendarState.eventSelection && // an existing event selected?
|
|
1793
|
-
!
|
|
1749
|
+
!this.matchesEvent // interaction DIDN'T start on an event
|
|
1794
1750
|
) {
|
|
1795
1751
|
context.dispatch({ type: 'UNSELECT_EVENT' });
|
|
1796
1752
|
}
|
|
1797
1753
|
}
|
|
1798
|
-
|
|
1754
|
+
this.isRecentPointerDateSelect = false;
|
|
1799
1755
|
};
|
|
1800
|
-
|
|
1756
|
+
let documentPointer = this.documentPointer = new PointerDragging(document);
|
|
1801
1757
|
documentPointer.shouldIgnoreMove = true;
|
|
1802
1758
|
documentPointer.shouldWatchScroll = false;
|
|
1803
1759
|
documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
|
|
@@ -1807,17 +1763,16 @@ var UnselectAuto = /** @class */ (function () {
|
|
|
1807
1763
|
*/
|
|
1808
1764
|
context.emitter.on('select', this.onSelect);
|
|
1809
1765
|
}
|
|
1810
|
-
|
|
1766
|
+
destroy() {
|
|
1811
1767
|
this.context.emitter.off('select', this.onSelect);
|
|
1812
1768
|
this.documentPointer.destroy();
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
}());
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1816
1771
|
|
|
1817
|
-
|
|
1772
|
+
const OPTION_REFINERS = {
|
|
1818
1773
|
fixedMirrorParent: common.identity,
|
|
1819
1774
|
};
|
|
1820
|
-
|
|
1775
|
+
const LISTENER_REFINERS = {
|
|
1821
1776
|
dateClick: common.identity,
|
|
1822
1777
|
eventDragStart: common.identity,
|
|
1823
1778
|
eventDragStop: common.identity,
|
|
@@ -1835,30 +1790,29 @@ Given an already instantiated draggable object for one-or-more elements,
|
|
|
1835
1790
|
Interprets any dragging as an attempt to drag an events that lives outside
|
|
1836
1791
|
of a calendar onto a calendar.
|
|
1837
1792
|
*/
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
var _this = this;
|
|
1793
|
+
class ExternalElementDragging {
|
|
1794
|
+
constructor(dragging, suppliedDragMeta) {
|
|
1841
1795
|
this.receivingContext = null;
|
|
1842
1796
|
this.droppableEvent = null; // will exist for all drags, even if create:false
|
|
1843
1797
|
this.suppliedDragMeta = null;
|
|
1844
1798
|
this.dragMeta = null;
|
|
1845
|
-
this.handleDragStart =
|
|
1846
|
-
|
|
1799
|
+
this.handleDragStart = (ev) => {
|
|
1800
|
+
this.dragMeta = this.buildDragMeta(ev.subjectEl);
|
|
1847
1801
|
};
|
|
1848
|
-
this.handleHitUpdate =
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1802
|
+
this.handleHitUpdate = (hit, isFinal, ev) => {
|
|
1803
|
+
let { dragging } = this.hitDragging;
|
|
1804
|
+
let receivingContext = null;
|
|
1805
|
+
let droppableEvent = null;
|
|
1806
|
+
let isInvalid = false;
|
|
1807
|
+
let interaction = {
|
|
1854
1808
|
affectedEvents: common.createEmptyEventStore(),
|
|
1855
1809
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1856
|
-
isEvent:
|
|
1810
|
+
isEvent: this.dragMeta.create,
|
|
1857
1811
|
};
|
|
1858
1812
|
if (hit) {
|
|
1859
1813
|
receivingContext = hit.context;
|
|
1860
|
-
if (
|
|
1861
|
-
droppableEvent = computeEventForDateSpan(hit.dateSpan,
|
|
1814
|
+
if (this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
|
|
1815
|
+
droppableEvent = computeEventForDateSpan(hit.dateSpan, this.dragMeta, receivingContext);
|
|
1862
1816
|
interaction.mutatedEvents = common.eventTupleToStore(droppableEvent);
|
|
1863
1817
|
isInvalid = !common.isInteractionValid(interaction, hit.dateProfile, receivingContext);
|
|
1864
1818
|
if (isInvalid) {
|
|
@@ -1867,7 +1821,7 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1867
1821
|
}
|
|
1868
1822
|
}
|
|
1869
1823
|
}
|
|
1870
|
-
|
|
1824
|
+
this.displayDrag(receivingContext, interaction);
|
|
1871
1825
|
// show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
|
|
1872
1826
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1873
1827
|
dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
|
|
@@ -1879,23 +1833,23 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1879
1833
|
}
|
|
1880
1834
|
if (!isFinal) {
|
|
1881
1835
|
dragging.setMirrorNeedsRevert(!droppableEvent);
|
|
1882
|
-
|
|
1883
|
-
|
|
1836
|
+
this.receivingContext = receivingContext;
|
|
1837
|
+
this.droppableEvent = droppableEvent;
|
|
1884
1838
|
}
|
|
1885
1839
|
};
|
|
1886
|
-
this.handleDragEnd =
|
|
1887
|
-
|
|
1888
|
-
|
|
1840
|
+
this.handleDragEnd = (pev) => {
|
|
1841
|
+
let { receivingContext, droppableEvent } = this;
|
|
1842
|
+
this.clearDrag();
|
|
1889
1843
|
if (receivingContext && droppableEvent) {
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
receivingContext.emitter.trigger('drop',
|
|
1844
|
+
let finalHit = this.hitDragging.finalHit;
|
|
1845
|
+
let finalView = finalHit.context.viewApi;
|
|
1846
|
+
let dragMeta = this.dragMeta;
|
|
1847
|
+
receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
|
|
1894
1848
|
if (dragMeta.create) {
|
|
1895
|
-
|
|
1849
|
+
let addingEvents = common.eventTupleToStore(droppableEvent);
|
|
1896
1850
|
receivingContext.dispatch({
|
|
1897
1851
|
type: 'MERGE_EVENTS',
|
|
1898
|
-
eventStore:
|
|
1852
|
+
eventStore: addingEvents,
|
|
1899
1853
|
});
|
|
1900
1854
|
if (pev.isTouch) {
|
|
1901
1855
|
receivingContext.dispatch({
|
|
@@ -1907,10 +1861,10 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1907
1861
|
receivingContext.emitter.trigger('eventReceive', {
|
|
1908
1862
|
event: new common.EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
|
|
1909
1863
|
relatedEvents: [],
|
|
1910
|
-
revert
|
|
1864
|
+
revert() {
|
|
1911
1865
|
receivingContext.dispatch({
|
|
1912
1866
|
type: 'REMOVE_EVENTS',
|
|
1913
|
-
eventStore:
|
|
1867
|
+
eventStore: addingEvents,
|
|
1914
1868
|
});
|
|
1915
1869
|
},
|
|
1916
1870
|
draggedEl: pev.subjectEl,
|
|
@@ -1918,17 +1872,17 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1918
1872
|
});
|
|
1919
1873
|
}
|
|
1920
1874
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
1875
|
+
this.receivingContext = null;
|
|
1876
|
+
this.droppableEvent = null;
|
|
1923
1877
|
};
|
|
1924
|
-
|
|
1878
|
+
let hitDragging = this.hitDragging = new HitDragging(dragging, common.interactionSettingsStore);
|
|
1925
1879
|
hitDragging.requireInitial = false; // will start outside of a component
|
|
1926
1880
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1927
1881
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
1928
1882
|
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1929
1883
|
this.suppliedDragMeta = suppliedDragMeta;
|
|
1930
1884
|
}
|
|
1931
|
-
|
|
1885
|
+
buildDragMeta(subjectEl) {
|
|
1932
1886
|
if (typeof this.suppliedDragMeta === 'object') {
|
|
1933
1887
|
return common.parseDragMeta(this.suppliedDragMeta);
|
|
1934
1888
|
}
|
|
@@ -1936,23 +1890,23 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1936
1890
|
return common.parseDragMeta(this.suppliedDragMeta(subjectEl));
|
|
1937
1891
|
}
|
|
1938
1892
|
return getDragMetaFromEl(subjectEl);
|
|
1939
|
-
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1893
|
+
}
|
|
1894
|
+
displayDrag(nextContext, state) {
|
|
1895
|
+
let prevContext = this.receivingContext;
|
|
1942
1896
|
if (prevContext && prevContext !== nextContext) {
|
|
1943
1897
|
prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1944
1898
|
}
|
|
1945
1899
|
if (nextContext) {
|
|
1946
|
-
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state
|
|
1900
|
+
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
|
|
1947
1901
|
}
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1902
|
+
}
|
|
1903
|
+
clearDrag() {
|
|
1950
1904
|
if (this.receivingContext) {
|
|
1951
1905
|
this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1952
1906
|
}
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1907
|
+
}
|
|
1908
|
+
canDropElOnCalendar(el, receivingContext) {
|
|
1909
|
+
let dropAccept = receivingContext.options.dropAccept;
|
|
1956
1910
|
if (typeof dropAccept === 'function') {
|
|
1957
1911
|
return dropAccept.call(receivingContext.calendarApi, el);
|
|
1958
1912
|
}
|
|
@@ -1960,45 +1914,43 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1960
1914
|
return Boolean(common.elementMatches(el, dropAccept));
|
|
1961
1915
|
}
|
|
1962
1916
|
return true;
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
}());
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1966
1919
|
// Utils for computing event store from the DragMeta
|
|
1967
1920
|
// ----------------------------------------------------------------------------------------------------
|
|
1968
1921
|
function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
1969
|
-
|
|
1970
|
-
for (
|
|
1971
|
-
var transform = _a[_i];
|
|
1922
|
+
let defProps = Object.assign({}, dragMeta.leftoverProps);
|
|
1923
|
+
for (let transform of context.pluginHooks.externalDefTransforms) {
|
|
1972
1924
|
tslib.__assign(defProps, transform(dateSpan, dragMeta));
|
|
1973
1925
|
}
|
|
1974
|
-
|
|
1975
|
-
|
|
1926
|
+
let { refined, extra } = common.refineEventDef(defProps, context);
|
|
1927
|
+
let def = common.parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
|
|
1976
1928
|
context);
|
|
1977
|
-
|
|
1929
|
+
let start = dateSpan.range.start;
|
|
1978
1930
|
// only rely on time info if drop zone is all-day,
|
|
1979
1931
|
// otherwise, we already know the time
|
|
1980
1932
|
if (dateSpan.allDay && dragMeta.startTime) {
|
|
1981
1933
|
start = context.dateEnv.add(start, dragMeta.startTime);
|
|
1982
1934
|
}
|
|
1983
|
-
|
|
1935
|
+
let end = dragMeta.duration ?
|
|
1984
1936
|
context.dateEnv.add(start, dragMeta.duration) :
|
|
1985
1937
|
common.getDefaultEventEnd(dateSpan.allDay, start, context);
|
|
1986
|
-
|
|
1987
|
-
return { def
|
|
1938
|
+
let instance = common.createEventInstance(def.defId, { start, end });
|
|
1939
|
+
return { def, instance };
|
|
1988
1940
|
}
|
|
1989
1941
|
// Utils for extracting data from element
|
|
1990
1942
|
// ----------------------------------------------------------------------------------------------------
|
|
1991
1943
|
function getDragMetaFromEl(el) {
|
|
1992
|
-
|
|
1993
|
-
|
|
1944
|
+
let str = getEmbeddedElData(el, 'event');
|
|
1945
|
+
let obj = str ?
|
|
1994
1946
|
JSON.parse(str) :
|
|
1995
1947
|
{ create: false }; // if no embedded data, assume no event creation
|
|
1996
1948
|
return common.parseDragMeta(obj);
|
|
1997
1949
|
}
|
|
1998
1950
|
common.config.dataAttrPrefix = '';
|
|
1999
1951
|
function getEmbeddedElData(el, name) {
|
|
2000
|
-
|
|
2001
|
-
|
|
1952
|
+
let prefix = common.config.dataAttrPrefix;
|
|
1953
|
+
let prefixedName = (prefix ? prefix + '-' : '') + name;
|
|
2002
1954
|
return el.getAttribute('data-' + prefixedName) || '';
|
|
2003
1955
|
}
|
|
2004
1956
|
|
|
@@ -2007,13 +1959,11 @@ Makes an element (that is *external* to any calendar) draggable.
|
|
|
2007
1959
|
Can pass in data that determines how an event will be created when dropped onto a calendar.
|
|
2008
1960
|
Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
|
|
2009
1961
|
*/
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
var dragging = _this.dragging;
|
|
2016
|
-
var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
|
|
1962
|
+
class ExternalDraggable {
|
|
1963
|
+
constructor(el, settings = {}) {
|
|
1964
|
+
this.handlePointerDown = (ev) => {
|
|
1965
|
+
let { dragging } = this;
|
|
1966
|
+
let { minDistance, longPressDelay } = this.settings;
|
|
2017
1967
|
dragging.minDistance =
|
|
2018
1968
|
minDistance != null ?
|
|
2019
1969
|
minDistance :
|
|
@@ -2023,15 +1973,15 @@ var ExternalDraggable = /** @class */ (function () {
|
|
|
2023
1973
|
(longPressDelay != null ? longPressDelay : common.BASE_OPTION_DEFAULTS.longPressDelay) :
|
|
2024
1974
|
0;
|
|
2025
1975
|
};
|
|
2026
|
-
this.handleDragStart =
|
|
1976
|
+
this.handleDragStart = (ev) => {
|
|
2027
1977
|
if (ev.isTouch &&
|
|
2028
|
-
|
|
1978
|
+
this.dragging.delay &&
|
|
2029
1979
|
ev.subjectEl.classList.contains('fc-event')) {
|
|
2030
|
-
|
|
1980
|
+
this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
|
|
2031
1981
|
}
|
|
2032
1982
|
};
|
|
2033
1983
|
this.settings = settings;
|
|
2034
|
-
|
|
1984
|
+
let dragging = this.dragging = new FeaturefulElementDragging(el);
|
|
2035
1985
|
dragging.touchScrollAllowed = false;
|
|
2036
1986
|
if (settings.itemSelector != null) {
|
|
2037
1987
|
dragging.pointer.selector = settings.itemSelector;
|
|
@@ -2043,11 +1993,10 @@ var ExternalDraggable = /** @class */ (function () {
|
|
|
2043
1993
|
dragging.emitter.on('dragstart', this.handleDragStart);
|
|
2044
1994
|
new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
|
|
2045
1995
|
}
|
|
2046
|
-
|
|
1996
|
+
destroy() {
|
|
2047
1997
|
this.dragging.destroy();
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
}());
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2051
2000
|
|
|
2052
2001
|
/*
|
|
2053
2002
|
Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
|
|
@@ -2055,45 +2004,43 @@ The third-party system is responsible for drawing the visuals effects of the dra
|
|
|
2055
2004
|
This class simply monitors for pointer movements and fires events.
|
|
2056
2005
|
It also has the ability to hide the moving element (the "mirror") during the drag.
|
|
2057
2006
|
*/
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
if (!_this.shouldIgnoreMove) {
|
|
2007
|
+
class InferredElementDragging extends common.ElementDragging {
|
|
2008
|
+
constructor(containerEl) {
|
|
2009
|
+
super(containerEl);
|
|
2010
|
+
this.shouldIgnoreMove = false;
|
|
2011
|
+
this.mirrorSelector = '';
|
|
2012
|
+
this.currentMirrorEl = null;
|
|
2013
|
+
this.handlePointerDown = (ev) => {
|
|
2014
|
+
this.emitter.trigger('pointerdown', ev);
|
|
2015
|
+
if (!this.shouldIgnoreMove) {
|
|
2068
2016
|
// fire dragstart right away. does not support delay or min-distance
|
|
2069
|
-
|
|
2017
|
+
this.emitter.trigger('dragstart', ev);
|
|
2070
2018
|
}
|
|
2071
2019
|
};
|
|
2072
|
-
|
|
2073
|
-
if (!
|
|
2074
|
-
|
|
2020
|
+
this.handlePointerMove = (ev) => {
|
|
2021
|
+
if (!this.shouldIgnoreMove) {
|
|
2022
|
+
this.emitter.trigger('dragmove', ev);
|
|
2075
2023
|
}
|
|
2076
2024
|
};
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
if (!
|
|
2025
|
+
this.handlePointerUp = (ev) => {
|
|
2026
|
+
this.emitter.trigger('pointerup', ev);
|
|
2027
|
+
if (!this.shouldIgnoreMove) {
|
|
2080
2028
|
// fire dragend right away. does not support a revert animation
|
|
2081
|
-
|
|
2029
|
+
this.emitter.trigger('dragend', ev);
|
|
2082
2030
|
}
|
|
2083
2031
|
};
|
|
2084
|
-
|
|
2085
|
-
pointer.emitter.on('pointerdown',
|
|
2086
|
-
pointer.emitter.on('pointermove',
|
|
2087
|
-
pointer.emitter.on('pointerup',
|
|
2088
|
-
return _this;
|
|
2032
|
+
let pointer = this.pointer = new PointerDragging(containerEl);
|
|
2033
|
+
pointer.emitter.on('pointerdown', this.handlePointerDown);
|
|
2034
|
+
pointer.emitter.on('pointermove', this.handlePointerMove);
|
|
2035
|
+
pointer.emitter.on('pointerup', this.handlePointerUp);
|
|
2089
2036
|
}
|
|
2090
|
-
|
|
2037
|
+
destroy() {
|
|
2091
2038
|
this.pointer.destroy();
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2039
|
+
}
|
|
2040
|
+
setIgnoreMove(bool) {
|
|
2094
2041
|
this.shouldIgnoreMove = bool;
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2042
|
+
}
|
|
2043
|
+
setMirrorIsVisible(bool) {
|
|
2097
2044
|
if (bool) {
|
|
2098
2045
|
// restore a previously hidden element.
|
|
2099
2046
|
// use the reference in case the selector class has already been removed.
|
|
@@ -2103,7 +2050,7 @@ var InferredElementDragging = /** @class */ (function (_super) {
|
|
|
2103
2050
|
}
|
|
2104
2051
|
}
|
|
2105
2052
|
else {
|
|
2106
|
-
|
|
2053
|
+
let mirrorEl = this.mirrorSelector
|
|
2107
2054
|
// TODO: somehow query FullCalendars WITHIN shadow-roots
|
|
2108
2055
|
? document.querySelector(this.mirrorSelector)
|
|
2109
2056
|
: null;
|
|
@@ -2112,17 +2059,16 @@ var InferredElementDragging = /** @class */ (function (_super) {
|
|
|
2112
2059
|
mirrorEl.style.visibility = 'hidden';
|
|
2113
2060
|
}
|
|
2114
2061
|
}
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
}(common.ElementDragging));
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2118
2064
|
|
|
2119
2065
|
/*
|
|
2120
2066
|
Bridges third-party drag-n-drop systems with FullCalendar.
|
|
2121
2067
|
Must be instantiated and destroyed by caller.
|
|
2122
2068
|
*/
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2069
|
+
class ThirdPartyDraggable {
|
|
2070
|
+
constructor(containerOrSettings, settings) {
|
|
2071
|
+
let containerEl = document;
|
|
2126
2072
|
if (
|
|
2127
2073
|
// wish we could just test instanceof EventTarget, but doesn't work in IE11
|
|
2128
2074
|
containerOrSettings === document ||
|
|
@@ -2133,7 +2079,7 @@ var ThirdPartyDraggable = /** @class */ (function () {
|
|
|
2133
2079
|
else {
|
|
2134
2080
|
settings = (containerOrSettings || {});
|
|
2135
2081
|
}
|
|
2136
|
-
|
|
2082
|
+
let dragging = this.dragging = new InferredElementDragging(containerEl);
|
|
2137
2083
|
if (typeof settings.itemSelector === 'string') {
|
|
2138
2084
|
dragging.pointer.selector = settings.itemSelector;
|
|
2139
2085
|
}
|
|
@@ -2145,11 +2091,10 @@ var ThirdPartyDraggable = /** @class */ (function () {
|
|
|
2145
2091
|
}
|
|
2146
2092
|
new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
|
|
2147
2093
|
}
|
|
2148
|
-
|
|
2094
|
+
destroy() {
|
|
2149
2095
|
this.dragging.destroy();
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
}());
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2153
2098
|
|
|
2154
2099
|
var main = common.createPlugin({
|
|
2155
2100
|
componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
|