@fullcalendar/interaction 5.10.1 → 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 +810 -864
- package/main.global.js +836 -906
- package/main.global.min.js +3 -3
- package/main.js +812 -866
- package/main.js.map +1 -1
- package/package.json +3 -3
package/main.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar
|
|
2
|
+
FullCalendar v6.0.0-beta.1
|
|
3
3
|
Docs & License: https://fullcalendar.io/
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2022 Adam Shaw
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
@@ -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,63 +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
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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;
|
|
653
640
|
// completely within the rect?
|
|
654
641
|
if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
|
|
655
642
|
if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
|
|
656
643
|
(!bestSide || bestSide.distance > topDist)) {
|
|
657
|
-
bestSide = { scrollCache
|
|
644
|
+
bestSide = { scrollCache, name: 'top', distance: topDist };
|
|
658
645
|
}
|
|
659
646
|
if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
|
|
660
647
|
(!bestSide || bestSide.distance > bottomDist)) {
|
|
661
|
-
bestSide = { scrollCache
|
|
648
|
+
bestSide = { scrollCache, name: 'bottom', distance: bottomDist };
|
|
662
649
|
}
|
|
663
650
|
if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
|
|
664
651
|
(!bestSide || bestSide.distance > leftDist)) {
|
|
665
|
-
bestSide = { scrollCache
|
|
652
|
+
bestSide = { scrollCache, name: 'left', distance: leftDist };
|
|
666
653
|
}
|
|
667
654
|
if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
|
|
668
655
|
(!bestSide || bestSide.distance > rightDist)) {
|
|
669
|
-
bestSide = { scrollCache
|
|
656
|
+
bestSide = { scrollCache, name: 'right', distance: rightDist };
|
|
670
657
|
}
|
|
671
658
|
}
|
|
672
659
|
}
|
|
673
660
|
return bestSide;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
return this.queryScrollEls(scrollStartEl).map(
|
|
661
|
+
}
|
|
662
|
+
buildCaches(scrollStartEl) {
|
|
663
|
+
return this.queryScrollEls(scrollStartEl).map((el) => {
|
|
677
664
|
if (el === window) {
|
|
678
665
|
return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
|
|
679
666
|
}
|
|
680
667
|
return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
|
|
681
668
|
});
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
for (
|
|
686
|
-
var query = _a[_i];
|
|
669
|
+
}
|
|
670
|
+
queryScrollEls(scrollStartEl) {
|
|
671
|
+
let els = [];
|
|
672
|
+
for (let query of this.scrollQuery) {
|
|
687
673
|
if (typeof query === 'object') {
|
|
688
674
|
els.push(query);
|
|
689
675
|
}
|
|
690
676
|
else {
|
|
691
|
-
els.push
|
|
677
|
+
els.push(...Array.prototype.slice.call(common.getElRoot(scrollStartEl).querySelectorAll(query)));
|
|
692
678
|
}
|
|
693
679
|
}
|
|
694
680
|
return els;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
}());
|
|
681
|
+
}
|
|
682
|
+
}
|
|
698
683
|
|
|
699
684
|
/*
|
|
700
685
|
Monitors dragging on an element. Has a number of high-level features:
|
|
@@ -702,27 +687,26 @@ Monitors dragging on an element. Has a number of high-level features:
|
|
|
702
687
|
- minimum wait time ("delay") before dragging
|
|
703
688
|
- a mirror element that follows the pointer
|
|
704
689
|
*/
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
_this.containerEl = containerEl;
|
|
690
|
+
class FeaturefulElementDragging extends common.ElementDragging {
|
|
691
|
+
constructor(containerEl, selector) {
|
|
692
|
+
super(containerEl);
|
|
693
|
+
this.containerEl = containerEl;
|
|
710
694
|
// options that can be directly set by caller
|
|
711
695
|
// the caller can also set the PointerDragging's options as well
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (!
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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;
|
|
726
710
|
common.preventSelection(document.body);
|
|
727
711
|
common.preventContextMenu(document.body);
|
|
728
712
|
// prevent links from being visited if there's an eventual drag.
|
|
@@ -731,95 +715,93 @@ var FeaturefulElementDragging = /** @class */ (function (_super) {
|
|
|
731
715
|
if (!ev.isTouch) {
|
|
732
716
|
ev.origEvent.preventDefault();
|
|
733
717
|
}
|
|
734
|
-
|
|
735
|
-
if (
|
|
736
|
-
!
|
|
718
|
+
this.emitter.trigger('pointerdown', ev);
|
|
719
|
+
if (this.isInteracting && // not destroyed via pointerdown handler
|
|
720
|
+
!this.pointer.shouldIgnoreMove) {
|
|
737
721
|
// actions related to initiating dragstart+dragmove+dragend...
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if (!
|
|
742
|
-
|
|
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);
|
|
743
727
|
}
|
|
744
728
|
}
|
|
745
729
|
}
|
|
746
730
|
};
|
|
747
|
-
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
-
if (!
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
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;
|
|
754
738
|
distanceSq = deltaX * deltaX + deltaY * deltaY;
|
|
755
739
|
if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
|
|
756
|
-
|
|
740
|
+
this.handleDistanceSurpassed(ev);
|
|
757
741
|
}
|
|
758
742
|
}
|
|
759
|
-
if (
|
|
743
|
+
if (this.isDragging) {
|
|
760
744
|
// a real pointer move? (not one simulated by scrolling)
|
|
761
745
|
if (ev.origEvent.type !== 'scroll') {
|
|
762
|
-
|
|
763
|
-
|
|
746
|
+
this.mirror.handleMove(ev.pageX, ev.pageY);
|
|
747
|
+
this.autoScroller.handleMove(ev.pageX, ev.pageY);
|
|
764
748
|
}
|
|
765
|
-
|
|
749
|
+
this.emitter.trigger('dragmove', ev);
|
|
766
750
|
}
|
|
767
751
|
}
|
|
768
752
|
};
|
|
769
|
-
|
|
770
|
-
if (
|
|
771
|
-
|
|
753
|
+
this.onPointerUp = (ev) => {
|
|
754
|
+
if (this.isInteracting) {
|
|
755
|
+
this.isInteracting = false;
|
|
772
756
|
common.allowSelection(document.body);
|
|
773
757
|
common.allowContextMenu(document.body);
|
|
774
|
-
|
|
775
|
-
if (
|
|
776
|
-
|
|
777
|
-
|
|
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
|
|
778
762
|
}
|
|
779
|
-
if (
|
|
780
|
-
clearTimeout(
|
|
781
|
-
|
|
763
|
+
if (this.delayTimeoutId) {
|
|
764
|
+
clearTimeout(this.delayTimeoutId);
|
|
765
|
+
this.delayTimeoutId = null;
|
|
782
766
|
}
|
|
783
767
|
}
|
|
784
768
|
};
|
|
785
|
-
|
|
786
|
-
pointer.emitter.on('pointerdown',
|
|
787
|
-
pointer.emitter.on('pointermove',
|
|
788
|
-
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);
|
|
789
773
|
if (selector) {
|
|
790
774
|
pointer.selector = selector;
|
|
791
775
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return _this;
|
|
776
|
+
this.mirror = new ElementMirror();
|
|
777
|
+
this.autoScroller = new AutoScroller();
|
|
795
778
|
}
|
|
796
|
-
|
|
779
|
+
destroy() {
|
|
797
780
|
this.pointer.destroy();
|
|
798
781
|
// HACK: simulate a pointer-up to end the current drag
|
|
799
782
|
// TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
|
|
800
783
|
this.onPointerUp({});
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
var _this = this;
|
|
784
|
+
}
|
|
785
|
+
startDelay(ev) {
|
|
804
786
|
if (typeof this.delay === 'number') {
|
|
805
|
-
this.delayTimeoutId = setTimeout(
|
|
806
|
-
|
|
807
|
-
|
|
787
|
+
this.delayTimeoutId = setTimeout(() => {
|
|
788
|
+
this.delayTimeoutId = null;
|
|
789
|
+
this.handleDelayEnd(ev);
|
|
808
790
|
}, this.delay); // not assignable to number!
|
|
809
791
|
}
|
|
810
792
|
else {
|
|
811
793
|
this.handleDelayEnd(ev);
|
|
812
794
|
}
|
|
813
|
-
}
|
|
814
|
-
|
|
795
|
+
}
|
|
796
|
+
handleDelayEnd(ev) {
|
|
815
797
|
this.isDelayEnded = true;
|
|
816
798
|
this.tryStartDrag(ev);
|
|
817
|
-
}
|
|
818
|
-
|
|
799
|
+
}
|
|
800
|
+
handleDistanceSurpassed(ev) {
|
|
819
801
|
this.isDistanceSurpassed = true;
|
|
820
802
|
this.tryStartDrag(ev);
|
|
821
|
-
}
|
|
822
|
-
|
|
803
|
+
}
|
|
804
|
+
tryStartDrag(ev) {
|
|
823
805
|
if (this.isDelayEnded && this.isDistanceSurpassed) {
|
|
824
806
|
if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
|
|
825
807
|
this.isDragging = true;
|
|
@@ -831,31 +813,30 @@ var FeaturefulElementDragging = /** @class */ (function (_super) {
|
|
|
831
813
|
}
|
|
832
814
|
}
|
|
833
815
|
}
|
|
834
|
-
}
|
|
835
|
-
|
|
816
|
+
}
|
|
817
|
+
tryStopDrag(ev) {
|
|
836
818
|
// .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
|
|
837
819
|
// that come from the document to fire beforehand. much more convenient this way.
|
|
838
820
|
this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
|
|
839
|
-
}
|
|
840
|
-
|
|
821
|
+
}
|
|
822
|
+
stopDrag(ev) {
|
|
841
823
|
this.isDragging = false;
|
|
842
824
|
this.emitter.trigger('dragend', ev);
|
|
843
|
-
}
|
|
825
|
+
}
|
|
844
826
|
// fill in the implementations...
|
|
845
|
-
|
|
827
|
+
setIgnoreMove(bool) {
|
|
846
828
|
this.pointer.shouldIgnoreMove = bool;
|
|
847
|
-
}
|
|
848
|
-
|
|
829
|
+
}
|
|
830
|
+
setMirrorIsVisible(bool) {
|
|
849
831
|
this.mirror.setIsVisible(bool);
|
|
850
|
-
}
|
|
851
|
-
|
|
832
|
+
}
|
|
833
|
+
setMirrorNeedsRevert(bool) {
|
|
852
834
|
this.mirrorNeedsRevert = bool;
|
|
853
|
-
}
|
|
854
|
-
|
|
835
|
+
}
|
|
836
|
+
setAutoScrollEnabled(bool) {
|
|
855
837
|
this.autoScroller.isEnabled = bool;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
}(common.ElementDragging));
|
|
838
|
+
}
|
|
839
|
+
}
|
|
859
840
|
|
|
860
841
|
/*
|
|
861
842
|
When this class is instantiated, it records the offset of an element (relative to the document topleft),
|
|
@@ -865,51 +846,46 @@ Does not access the DOM after instantiation, so highly performant.
|
|
|
865
846
|
Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
|
|
866
847
|
and an determine if a given point is inside the combined clipping rectangle.
|
|
867
848
|
*/
|
|
868
|
-
|
|
869
|
-
|
|
849
|
+
class OffsetTracker {
|
|
850
|
+
constructor(el) {
|
|
870
851
|
this.origRect = common.computeRect(el);
|
|
871
852
|
// will work fine for divs that have overflow:hidden
|
|
872
|
-
this.scrollCaches = common.getClippingParents(el).map(
|
|
853
|
+
this.scrollCaches = common.getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
|
|
873
854
|
}
|
|
874
|
-
|
|
875
|
-
for (
|
|
876
|
-
var scrollCache = _a[_i];
|
|
855
|
+
destroy() {
|
|
856
|
+
for (let scrollCache of this.scrollCaches) {
|
|
877
857
|
scrollCache.destroy();
|
|
878
858
|
}
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
for (
|
|
883
|
-
var scrollCache = _a[_i];
|
|
859
|
+
}
|
|
860
|
+
computeLeft() {
|
|
861
|
+
let left = this.origRect.left;
|
|
862
|
+
for (let scrollCache of this.scrollCaches) {
|
|
884
863
|
left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
|
|
885
864
|
}
|
|
886
865
|
return left;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
for (
|
|
891
|
-
var scrollCache = _a[_i];
|
|
866
|
+
}
|
|
867
|
+
computeTop() {
|
|
868
|
+
let top = this.origRect.top;
|
|
869
|
+
for (let scrollCache of this.scrollCaches) {
|
|
892
870
|
top += scrollCache.origScrollTop - scrollCache.getScrollTop();
|
|
893
871
|
}
|
|
894
872
|
return top;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
for (
|
|
899
|
-
var scrollCache = _a[_i];
|
|
873
|
+
}
|
|
874
|
+
isWithinClipping(pageX, pageY) {
|
|
875
|
+
let point = { left: pageX, top: pageY };
|
|
876
|
+
for (let scrollCache of this.scrollCaches) {
|
|
900
877
|
if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
|
|
901
878
|
!common.pointInsideRect(point, scrollCache.clientRect)) {
|
|
902
879
|
return false;
|
|
903
880
|
}
|
|
904
881
|
}
|
|
905
882
|
return true;
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
}());
|
|
883
|
+
}
|
|
884
|
+
}
|
|
909
885
|
// certain clipping containers should never constrain interactions, like <html> and <body>
|
|
910
886
|
// https://github.com/fullcalendar/fullcalendar/issues/3615
|
|
911
887
|
function isIgnoredClipping(node) {
|
|
912
|
-
|
|
888
|
+
let tagName = node.tagName;
|
|
913
889
|
return tagName === 'HTML' || tagName === 'BODY';
|
|
914
890
|
}
|
|
915
891
|
|
|
@@ -926,50 +902,49 @@ emits:
|
|
|
926
902
|
- (hitchange - again, to null, if ended over a hit)
|
|
927
903
|
- dragend
|
|
928
904
|
*/
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
var _this = this;
|
|
905
|
+
class HitDragging {
|
|
906
|
+
constructor(dragging, droppableStore) {
|
|
932
907
|
// options that can be set by caller
|
|
933
908
|
this.useSubjectCenter = false;
|
|
934
909
|
this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
|
|
935
910
|
this.initialHit = null;
|
|
936
911
|
this.movingHit = null;
|
|
937
912
|
this.finalHit = null; // won't ever be populated if shouldIgnoreMove
|
|
938
|
-
this.handlePointerDown =
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
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) {
|
|
946
921
|
dragging.setIgnoreMove(false);
|
|
947
922
|
// TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
|
|
948
|
-
|
|
923
|
+
this.emitter.trigger('pointerdown', ev);
|
|
949
924
|
}
|
|
950
925
|
else {
|
|
951
926
|
dragging.setIgnoreMove(true);
|
|
952
927
|
}
|
|
953
928
|
};
|
|
954
|
-
this.handleDragStart =
|
|
955
|
-
|
|
956
|
-
|
|
929
|
+
this.handleDragStart = (ev) => {
|
|
930
|
+
this.emitter.trigger('dragstart', ev);
|
|
931
|
+
this.handleMove(ev, true); // force = fire even if initially null
|
|
957
932
|
};
|
|
958
|
-
this.handleDragMove =
|
|
959
|
-
|
|
960
|
-
|
|
933
|
+
this.handleDragMove = (ev) => {
|
|
934
|
+
this.emitter.trigger('dragmove', ev);
|
|
935
|
+
this.handleMove(ev);
|
|
961
936
|
};
|
|
962
|
-
this.handlePointerUp =
|
|
963
|
-
|
|
964
|
-
|
|
937
|
+
this.handlePointerUp = (ev) => {
|
|
938
|
+
this.releaseHits();
|
|
939
|
+
this.emitter.trigger('pointerup', ev);
|
|
965
940
|
};
|
|
966
|
-
this.handleDragEnd =
|
|
967
|
-
if (
|
|
968
|
-
|
|
941
|
+
this.handleDragEnd = (ev) => {
|
|
942
|
+
if (this.movingHit) {
|
|
943
|
+
this.emitter.trigger('hitupdate', null, true, ev);
|
|
969
944
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
945
|
+
this.finalHit = this.movingHit;
|
|
946
|
+
this.movingHit = null;
|
|
947
|
+
this.emitter.trigger('dragend', ev);
|
|
973
948
|
};
|
|
974
949
|
this.droppableStore = droppableStore;
|
|
975
950
|
dragging.emitter.on('pointerdown', this.handlePointerDown);
|
|
@@ -982,19 +957,19 @@ var HitDragging = /** @class */ (function () {
|
|
|
982
957
|
}
|
|
983
958
|
// sets initialHit
|
|
984
959
|
// sets coordAdjust
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
960
|
+
processFirstCoord(ev) {
|
|
961
|
+
let origPoint = { left: ev.pageX, top: ev.pageY };
|
|
962
|
+
let adjustedPoint = origPoint;
|
|
963
|
+
let subjectEl = ev.subjectEl;
|
|
964
|
+
let subjectRect;
|
|
990
965
|
if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
|
|
991
966
|
subjectRect = common.computeRect(subjectEl);
|
|
992
967
|
adjustedPoint = common.constrainPoint(adjustedPoint, subjectRect);
|
|
993
968
|
}
|
|
994
|
-
|
|
969
|
+
let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
|
|
995
970
|
if (initialHit) {
|
|
996
971
|
if (this.useSubjectCenter && subjectRect) {
|
|
997
|
-
|
|
972
|
+
let slicedSubjectRect = common.intersectRects(subjectRect, initialHit.rect);
|
|
998
973
|
if (slicedSubjectRect) {
|
|
999
974
|
adjustedPoint = common.getRectCenter(slicedSubjectRect);
|
|
1000
975
|
}
|
|
@@ -1004,47 +979,47 @@ var HitDragging = /** @class */ (function () {
|
|
|
1004
979
|
else {
|
|
1005
980
|
this.coordAdjust = { left: 0, top: 0 };
|
|
1006
981
|
}
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
|
|
982
|
+
}
|
|
983
|
+
handleMove(ev, forceHandle) {
|
|
984
|
+
let hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
|
|
1010
985
|
if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
|
|
1011
986
|
this.movingHit = hit;
|
|
1012
987
|
this.emitter.trigger('hitupdate', hit, false, ev);
|
|
1013
988
|
}
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
this.offsetTrackers = common.mapHash(this.droppableStore,
|
|
989
|
+
}
|
|
990
|
+
prepareHits() {
|
|
991
|
+
this.offsetTrackers = common.mapHash(this.droppableStore, (interactionSettings) => {
|
|
1017
992
|
interactionSettings.component.prepareHits();
|
|
1018
993
|
return new OffsetTracker(interactionSettings.el);
|
|
1019
994
|
});
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
for (
|
|
995
|
+
}
|
|
996
|
+
releaseHits() {
|
|
997
|
+
let { offsetTrackers } = this;
|
|
998
|
+
for (let id in offsetTrackers) {
|
|
1024
999
|
offsetTrackers[id].destroy();
|
|
1025
1000
|
}
|
|
1026
1001
|
this.offsetTrackers = {};
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
for (
|
|
1032
|
-
|
|
1033
|
-
|
|
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];
|
|
1034
1009
|
if (offsetTracker && // wasn't destroyed mid-drag
|
|
1035
1010
|
offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
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;
|
|
1043
1018
|
if (
|
|
1044
1019
|
// must be within the element's bounds
|
|
1045
1020
|
positionLeft >= 0 && positionLeft < width &&
|
|
1046
1021
|
positionTop >= 0 && positionTop < height) {
|
|
1047
|
-
|
|
1022
|
+
let hit = component.queryHit(positionLeft, positionTop, width, height);
|
|
1048
1023
|
if (hit && (
|
|
1049
1024
|
// make sure the hit is within activeRange, meaning it's not a dead cell
|
|
1050
1025
|
common.rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
|
|
@@ -1062,9 +1037,8 @@ var HitDragging = /** @class */ (function () {
|
|
|
1062
1037
|
}
|
|
1063
1038
|
}
|
|
1064
1039
|
return bestHit;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
}());
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1068
1042
|
function isHitsEqual(hit0, hit1) {
|
|
1069
1043
|
if (!hit0 && !hit1) {
|
|
1070
1044
|
return true;
|
|
@@ -1076,9 +1050,8 @@ function isHitsEqual(hit0, hit1) {
|
|
|
1076
1050
|
}
|
|
1077
1051
|
|
|
1078
1052
|
function buildDatePointApiWithContext(dateSpan, context) {
|
|
1079
|
-
|
|
1080
|
-
for (
|
|
1081
|
-
var transform = _a[_i];
|
|
1053
|
+
let props = {};
|
|
1054
|
+
for (let transform of context.pluginHooks.datePointTransforms) {
|
|
1082
1055
|
tslib.__assign(props, transform(dateSpan, context));
|
|
1083
1056
|
}
|
|
1084
1057
|
tslib.__assign(props, buildDatePointApi(dateSpan, context.dateEnv));
|
|
@@ -1096,74 +1069,70 @@ function buildDatePointApi(span, dateEnv) {
|
|
|
1096
1069
|
Monitors when the user clicks on a specific date/time of a component.
|
|
1097
1070
|
A pointerdown+pointerup on the same "hit" constitutes a click.
|
|
1098
1071
|
*/
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
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;
|
|
1106
1078
|
// do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
|
|
1107
|
-
dragging.setIgnoreMove(!
|
|
1079
|
+
dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
|
|
1108
1080
|
};
|
|
1109
1081
|
// won't even fire if moving was ignored
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1082
|
+
this.handleDragEnd = (ev) => {
|
|
1083
|
+
let { component } = this;
|
|
1084
|
+
let { pointer } = this.dragging;
|
|
1113
1085
|
if (!pointer.wasTouchScroll) {
|
|
1114
|
-
|
|
1086
|
+
let { initialHit, finalHit } = this.hitDragging;
|
|
1115
1087
|
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
|
|
1116
|
-
|
|
1117
|
-
|
|
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 });
|
|
1118
1090
|
context.emitter.trigger('dateClick', arg);
|
|
1119
1091
|
}
|
|
1120
1092
|
}
|
|
1121
1093
|
};
|
|
1122
1094
|
// we DO want to watch pointer moves because otherwise finalHit won't get populated
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
hitDragging.emitter.on('pointerdown',
|
|
1127
|
-
hitDragging.emitter.on('dragend',
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
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() {
|
|
1131
1102
|
this.dragging.destroy();
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
}(common.Interaction));
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1135
1105
|
|
|
1136
1106
|
/*
|
|
1137
1107
|
Tracks when the user selects a portion of time of a component,
|
|
1138
1108
|
constituted by a drag over date cells, with a possible delay at the beginning of the drag.
|
|
1139
1109
|
*/
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
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 &&
|
|
1149
1118
|
component.isValidDateDownEl(ev.origEvent.target);
|
|
1150
1119
|
// don't bother to watch expensive moves if component won't do selection
|
|
1151
1120
|
dragging.setIgnoreMove(!canSelect);
|
|
1152
1121
|
// if touch, require user to hold down
|
|
1153
1122
|
dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
|
|
1154
1123
|
};
|
|
1155
|
-
|
|
1156
|
-
|
|
1124
|
+
this.handleDragStart = (ev) => {
|
|
1125
|
+
this.component.context.calendarApi.unselect(ev); // unselect previous selections
|
|
1157
1126
|
};
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1127
|
+
this.handleHitUpdate = (hit, isFinal) => {
|
|
1128
|
+
let { context } = this.component;
|
|
1129
|
+
let dragSelection = null;
|
|
1130
|
+
let isInvalid = false;
|
|
1162
1131
|
if (hit) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
&&
|
|
1166
|
-
&& !
|
|
1132
|
+
let initialHit = this.hitDragging.initialHit;
|
|
1133
|
+
let disallowed = hit.componentId === initialHit.componentId
|
|
1134
|
+
&& this.isHitComboAllowed
|
|
1135
|
+
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1167
1136
|
if (!disallowed) {
|
|
1168
1137
|
dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
|
|
1169
1138
|
}
|
|
@@ -1185,56 +1154,53 @@ var DateSelecting = /** @class */ (function (_super) {
|
|
|
1185
1154
|
common.disableCursor();
|
|
1186
1155
|
}
|
|
1187
1156
|
if (!isFinal) {
|
|
1188
|
-
|
|
1157
|
+
this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
|
|
1189
1158
|
}
|
|
1190
1159
|
};
|
|
1191
|
-
|
|
1192
|
-
if (
|
|
1160
|
+
this.handlePointerUp = (pev) => {
|
|
1161
|
+
if (this.dragSelection) {
|
|
1193
1162
|
// selection is already rendered, so just need to report selection
|
|
1194
|
-
common.triggerDateSelect(
|
|
1195
|
-
|
|
1163
|
+
common.triggerDateSelect(this.dragSelection, pev, this.component.context);
|
|
1164
|
+
this.dragSelection = null;
|
|
1196
1165
|
}
|
|
1197
1166
|
};
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1167
|
+
let { component } = settings;
|
|
1168
|
+
let { options } = component.context;
|
|
1169
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1201
1170
|
dragging.touchScrollAllowed = false;
|
|
1202
1171
|
dragging.minDistance = options.selectMinDistance || 0;
|
|
1203
1172
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1204
|
-
|
|
1205
|
-
hitDragging.emitter.on('pointerdown',
|
|
1206
|
-
hitDragging.emitter.on('dragstart',
|
|
1207
|
-
hitDragging.emitter.on('hitupdate',
|
|
1208
|
-
hitDragging.emitter.on('pointerup',
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
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() {
|
|
1212
1180
|
this.dragging.destroy();
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
}(common.Interaction));
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1216
1183
|
function getComponentTouchDelay$1(component) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1184
|
+
let { options } = component.context;
|
|
1185
|
+
let delay = options.selectLongPressDelay;
|
|
1219
1186
|
if (delay == null) {
|
|
1220
1187
|
delay = options.longPressDelay;
|
|
1221
1188
|
}
|
|
1222
1189
|
return delay;
|
|
1223
1190
|
}
|
|
1224
1191
|
function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1192
|
+
let dateSpan0 = hit0.dateSpan;
|
|
1193
|
+
let dateSpan1 = hit1.dateSpan;
|
|
1194
|
+
let ms = [
|
|
1228
1195
|
dateSpan0.range.start,
|
|
1229
1196
|
dateSpan0.range.end,
|
|
1230
1197
|
dateSpan1.range.start,
|
|
1231
1198
|
dateSpan1.range.end,
|
|
1232
1199
|
];
|
|
1233
1200
|
ms.sort(common.compareNumbers);
|
|
1234
|
-
|
|
1235
|
-
for (
|
|
1236
|
-
|
|
1237
|
-
var res = transformer(hit0, hit1);
|
|
1201
|
+
let props = {};
|
|
1202
|
+
for (let transformer of dateSelectionTransformers) {
|
|
1203
|
+
let res = transformer(hit0, hit1);
|
|
1238
1204
|
if (res === false) {
|
|
1239
1205
|
return null;
|
|
1240
1206
|
}
|
|
@@ -1247,30 +1213,29 @@ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
|
1247
1213
|
return props;
|
|
1248
1214
|
}
|
|
1249
1215
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
var _this = _super.call(this, settings) || this;
|
|
1216
|
+
class EventDragging extends common.Interaction {
|
|
1217
|
+
constructor(settings) {
|
|
1218
|
+
super(settings);
|
|
1254
1219
|
// internal state
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
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);
|
|
1274
1239
|
dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
|
|
1275
1240
|
dragging.delay =
|
|
1276
1241
|
// only do a touch delay if touch and this event hasn't been selected yet
|
|
@@ -1284,58 +1249,58 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1284
1249
|
mirror.parentNode = common.elementClosest(origTarget, '.fc');
|
|
1285
1250
|
}
|
|
1286
1251
|
mirror.revertDuration = options.dragRevertDuration;
|
|
1287
|
-
|
|
1252
|
+
let isValid = component.isValidSegDownEl(origTarget) &&
|
|
1288
1253
|
!common.elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
|
|
1289
1254
|
dragging.setIgnoreMove(!isValid);
|
|
1290
1255
|
// disable dragging for elements that are resizable (ie, selectable)
|
|
1291
1256
|
// but are not draggable
|
|
1292
|
-
|
|
1257
|
+
this.isDragging = isValid &&
|
|
1293
1258
|
ev.subjectEl.classList.contains('fc-event-draggable');
|
|
1294
1259
|
};
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1260
|
+
this.handleDragStart = (ev) => {
|
|
1261
|
+
let initialContext = this.component.context;
|
|
1262
|
+
let eventRange = this.eventRange;
|
|
1263
|
+
let eventInstanceId = eventRange.instance.instanceId;
|
|
1299
1264
|
if (ev.isTouch) {
|
|
1300
1265
|
// need to select a different event?
|
|
1301
|
-
if (eventInstanceId !==
|
|
1302
|
-
initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId
|
|
1266
|
+
if (eventInstanceId !== this.component.props.eventSelection) {
|
|
1267
|
+
initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId });
|
|
1303
1268
|
}
|
|
1304
1269
|
}
|
|
1305
1270
|
else {
|
|
1306
1271
|
// if now using mouse, but was previous touch interaction, clear selected event
|
|
1307
1272
|
initialContext.dispatch({ type: 'UNSELECT_EVENT' });
|
|
1308
1273
|
}
|
|
1309
|
-
if (
|
|
1274
|
+
if (this.isDragging) {
|
|
1310
1275
|
initialContext.calendarApi.unselect(ev); // unselect *date* selection
|
|
1311
1276
|
initialContext.emitter.trigger('eventDragStart', {
|
|
1312
|
-
el:
|
|
1277
|
+
el: this.subjectEl,
|
|
1313
1278
|
event: new common.EventApi(initialContext, eventRange.def, eventRange.instance),
|
|
1314
1279
|
jsEvent: ev.origEvent,
|
|
1315
1280
|
view: initialContext.viewApi,
|
|
1316
1281
|
});
|
|
1317
1282
|
}
|
|
1318
1283
|
};
|
|
1319
|
-
|
|
1320
|
-
if (!
|
|
1284
|
+
this.handleHitUpdate = (hit, isFinal) => {
|
|
1285
|
+
if (!this.isDragging) {
|
|
1321
1286
|
return;
|
|
1322
1287
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1288
|
+
let relevantEvents = this.relevantEvents;
|
|
1289
|
+
let initialHit = this.hitDragging.initialHit;
|
|
1290
|
+
let initialContext = this.component.context;
|
|
1326
1291
|
// states based on new hit
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1292
|
+
let receivingContext = null;
|
|
1293
|
+
let mutation = null;
|
|
1294
|
+
let mutatedRelevantEvents = null;
|
|
1295
|
+
let isInvalid = false;
|
|
1296
|
+
let interaction = {
|
|
1332
1297
|
affectedEvents: relevantEvents,
|
|
1333
1298
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1334
1299
|
isEvent: true,
|
|
1335
1300
|
};
|
|
1336
1301
|
if (hit) {
|
|
1337
1302
|
receivingContext = hit.context;
|
|
1338
|
-
|
|
1303
|
+
let receivingOptions = receivingContext.options;
|
|
1339
1304
|
if (initialContext === receivingContext ||
|
|
1340
1305
|
(receivingOptions.editable && receivingOptions.droppable)) {
|
|
1341
1306
|
mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
|
|
@@ -1354,7 +1319,7 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1354
1319
|
receivingContext = null;
|
|
1355
1320
|
}
|
|
1356
1321
|
}
|
|
1357
|
-
|
|
1322
|
+
this.displayDrag(receivingContext, interaction);
|
|
1358
1323
|
if (!isInvalid) {
|
|
1359
1324
|
common.enableCursor();
|
|
1360
1325
|
}
|
|
@@ -1366,140 +1331,138 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1366
1331
|
isHitsEqual(initialHit, hit)) {
|
|
1367
1332
|
mutation = null;
|
|
1368
1333
|
}
|
|
1369
|
-
|
|
1334
|
+
this.dragging.setMirrorNeedsRevert(!mutation);
|
|
1370
1335
|
// render the mirror if no already-rendered mirror
|
|
1371
1336
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1372
|
-
|
|
1337
|
+
this.dragging.setMirrorIsVisible(!hit || !common.getElRoot(this.subjectEl).querySelector('.fc-event-mirror'));
|
|
1373
1338
|
// assign states based on new hit
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1339
|
+
this.receivingContext = receivingContext;
|
|
1340
|
+
this.validMutation = mutation;
|
|
1341
|
+
this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
1377
1342
|
}
|
|
1378
1343
|
};
|
|
1379
|
-
|
|
1380
|
-
if (!
|
|
1381
|
-
|
|
1344
|
+
this.handlePointerUp = () => {
|
|
1345
|
+
if (!this.isDragging) {
|
|
1346
|
+
this.cleanup(); // because handleDragEnd won't fire
|
|
1382
1347
|
}
|
|
1383
1348
|
};
|
|
1384
|
-
|
|
1385
|
-
if (
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
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,
|
|
1398
1363
|
event: eventApi,
|
|
1399
1364
|
jsEvent: ev.origEvent,
|
|
1400
1365
|
view: initialView,
|
|
1401
1366
|
});
|
|
1402
1367
|
if (validMutation) {
|
|
1403
1368
|
// dropped within same calendar
|
|
1404
|
-
if (
|
|
1405
|
-
|
|
1406
|
-
|
|
1369
|
+
if (receivingContext === initialContext) {
|
|
1370
|
+
let updatedEventApi = new common.EventApi(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1371
|
+
initialContext.dispatch({
|
|
1407
1372
|
type: 'MERGE_EVENTS',
|
|
1408
|
-
eventStore:
|
|
1373
|
+
eventStore: mutatedRelevantEvents,
|
|
1409
1374
|
});
|
|
1410
|
-
|
|
1375
|
+
let eventChangeArg = {
|
|
1411
1376
|
oldEvent: eventApi,
|
|
1412
1377
|
event: updatedEventApi,
|
|
1413
|
-
relatedEvents: common.buildEventApis(
|
|
1414
|
-
revert
|
|
1415
|
-
|
|
1378
|
+
relatedEvents: common.buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
|
|
1379
|
+
revert() {
|
|
1380
|
+
initialContext.dispatch({
|
|
1416
1381
|
type: 'MERGE_EVENTS',
|
|
1417
|
-
eventStore:
|
|
1382
|
+
eventStore: relevantEvents, // the pre-change data
|
|
1418
1383
|
});
|
|
1419
1384
|
},
|
|
1420
1385
|
};
|
|
1421
|
-
|
|
1422
|
-
for (
|
|
1423
|
-
|
|
1424
|
-
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));
|
|
1425
1389
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
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);
|
|
1428
1392
|
// dropped in different calendar
|
|
1429
1393
|
}
|
|
1430
|
-
else if (
|
|
1431
|
-
|
|
1394
|
+
else if (receivingContext) {
|
|
1395
|
+
let eventRemoveArg = {
|
|
1432
1396
|
event: eventApi,
|
|
1433
|
-
relatedEvents: common.buildEventApis(
|
|
1434
|
-
revert
|
|
1435
|
-
|
|
1397
|
+
relatedEvents: common.buildEventApis(relevantEvents, initialContext, eventInstance),
|
|
1398
|
+
revert() {
|
|
1399
|
+
initialContext.dispatch({
|
|
1436
1400
|
type: 'MERGE_EVENTS',
|
|
1437
|
-
eventStore:
|
|
1401
|
+
eventStore: relevantEvents,
|
|
1438
1402
|
});
|
|
1439
1403
|
},
|
|
1440
1404
|
};
|
|
1441
|
-
|
|
1442
|
-
|
|
1405
|
+
initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
|
|
1406
|
+
initialContext.dispatch({
|
|
1443
1407
|
type: 'REMOVE_EVENTS',
|
|
1444
|
-
eventStore:
|
|
1408
|
+
eventStore: relevantEvents,
|
|
1445
1409
|
});
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
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({
|
|
1451
1415
|
type: 'MERGE_EVENTS',
|
|
1452
|
-
eventStore:
|
|
1416
|
+
eventStore: mutatedRelevantEvents,
|
|
1453
1417
|
});
|
|
1454
|
-
|
|
1418
|
+
let eventAddArg = {
|
|
1455
1419
|
event: addedEventApi,
|
|
1456
|
-
relatedEvents: common.buildEventApis(
|
|
1457
|
-
revert
|
|
1458
|
-
|
|
1420
|
+
relatedEvents: common.buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
|
|
1421
|
+
revert() {
|
|
1422
|
+
receivingContext.dispatch({
|
|
1459
1423
|
type: 'REMOVE_EVENTS',
|
|
1460
|
-
eventStore:
|
|
1424
|
+
eventStore: mutatedRelevantEvents,
|
|
1461
1425
|
});
|
|
1462
1426
|
},
|
|
1463
1427
|
};
|
|
1464
|
-
|
|
1428
|
+
receivingContext.emitter.trigger('eventAdd', eventAddArg);
|
|
1465
1429
|
if (ev.isTouch) {
|
|
1466
|
-
|
|
1430
|
+
receivingContext.dispatch({
|
|
1467
1431
|
type: 'SELECT_EVENT',
|
|
1468
1432
|
eventInstanceId: eventInstance.instanceId,
|
|
1469
1433
|
});
|
|
1470
1434
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
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 }));
|
|
1473
1437
|
}
|
|
1474
1438
|
}
|
|
1475
1439
|
else {
|
|
1476
|
-
|
|
1440
|
+
initialContext.emitter.trigger('_noEventDrop');
|
|
1477
1441
|
}
|
|
1478
1442
|
}
|
|
1479
|
-
|
|
1443
|
+
this.cleanup();
|
|
1480
1444
|
};
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1445
|
+
let { component } = this;
|
|
1446
|
+
let { options } = component.context;
|
|
1447
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1484
1448
|
dragging.pointer.selector = EventDragging.SELECTOR;
|
|
1485
1449
|
dragging.touchScrollAllowed = false;
|
|
1486
1450
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
1487
|
-
|
|
1451
|
+
let hitDragging = this.hitDragging = new HitDragging(this.dragging, common.interactionSettingsStore);
|
|
1488
1452
|
hitDragging.useSubjectCenter = settings.useEventCenter;
|
|
1489
|
-
hitDragging.emitter.on('pointerdown',
|
|
1490
|
-
hitDragging.emitter.on('dragstart',
|
|
1491
|
-
hitDragging.emitter.on('hitupdate',
|
|
1492
|
-
hitDragging.emitter.on('pointerup',
|
|
1493
|
-
hitDragging.emitter.on('dragend',
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
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() {
|
|
1497
1460
|
this.dragging.destroy();
|
|
1498
|
-
}
|
|
1461
|
+
}
|
|
1499
1462
|
// render a drag state on the next receivingCalendar
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1463
|
+
displayDrag(nextContext, state) {
|
|
1464
|
+
let initialContext = this.component.context;
|
|
1465
|
+
let prevContext = this.receivingContext;
|
|
1503
1466
|
// does the previous calendar need to be cleared?
|
|
1504
1467
|
if (prevContext && prevContext !== nextContext) {
|
|
1505
1468
|
// does the initial calendar need to be cleared?
|
|
@@ -1520,12 +1483,12 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1520
1483
|
}
|
|
1521
1484
|
}
|
|
1522
1485
|
if (nextContext) {
|
|
1523
|
-
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state
|
|
1486
|
+
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
|
|
1524
1487
|
}
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1488
|
+
}
|
|
1489
|
+
clearDrag() {
|
|
1490
|
+
let initialCalendar = this.component.context;
|
|
1491
|
+
let { receivingContext } = this;
|
|
1529
1492
|
if (receivingContext) {
|
|
1530
1493
|
receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1531
1494
|
}
|
|
@@ -1533,8 +1496,8 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1533
1496
|
if (initialCalendar !== receivingContext) {
|
|
1534
1497
|
initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1535
1498
|
}
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1499
|
+
}
|
|
1500
|
+
cleanup() {
|
|
1538
1501
|
this.subjectSeg = null;
|
|
1539
1502
|
this.isDragging = false;
|
|
1540
1503
|
this.eventRange = null;
|
|
@@ -1542,18 +1505,17 @@ var EventDragging = /** @class */ (function (_super) {
|
|
|
1542
1505
|
this.receivingContext = null;
|
|
1543
1506
|
this.validMutation = null;
|
|
1544
1507
|
this.mutatedRelevantEvents = null;
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
}(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';
|
|
1551
1513
|
function computeEventMutation(hit0, hit1, massagers) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
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 = {};
|
|
1557
1519
|
if (dateSpan0.allDay !== dateSpan1.allDay) {
|
|
1558
1520
|
standardProps.allDay = dateSpan1.allDay;
|
|
1559
1521
|
standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
|
|
@@ -1563,59 +1525,57 @@ function computeEventMutation(hit0, hit1, massagers) {
|
|
|
1563
1525
|
date0 = common.startOfDay(date0);
|
|
1564
1526
|
}
|
|
1565
1527
|
}
|
|
1566
|
-
|
|
1528
|
+
let delta = common.diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
|
|
1567
1529
|
hit0.largeUnit :
|
|
1568
1530
|
null);
|
|
1569
1531
|
if (delta.milliseconds) { // has hours/minutes/seconds
|
|
1570
1532
|
standardProps.allDay = false;
|
|
1571
1533
|
}
|
|
1572
|
-
|
|
1534
|
+
let mutation = {
|
|
1573
1535
|
datesDelta: delta,
|
|
1574
|
-
standardProps
|
|
1536
|
+
standardProps,
|
|
1575
1537
|
};
|
|
1576
|
-
for (
|
|
1577
|
-
var massager = massagers_1[_i];
|
|
1538
|
+
for (let massager of massagers) {
|
|
1578
1539
|
massager(mutation, hit0, hit1);
|
|
1579
1540
|
}
|
|
1580
1541
|
return mutation;
|
|
1581
1542
|
}
|
|
1582
1543
|
function getComponentTouchDelay(component) {
|
|
1583
|
-
|
|
1584
|
-
|
|
1544
|
+
let { options } = component.context;
|
|
1545
|
+
let delay = options.eventLongPressDelay;
|
|
1585
1546
|
if (delay == null) {
|
|
1586
1547
|
delay = options.longPressDelay;
|
|
1587
1548
|
}
|
|
1588
1549
|
return delay;
|
|
1589
1550
|
}
|
|
1590
1551
|
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
var _this = _super.call(this, settings) || this;
|
|
1552
|
+
class EventResizing extends common.Interaction {
|
|
1553
|
+
constructor(settings) {
|
|
1554
|
+
super(settings);
|
|
1595
1555
|
// internal state
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
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;
|
|
1608
1568
|
// if touch, need to be working with a selected event
|
|
1609
|
-
|
|
1610
|
-
(ev.isTouch &&
|
|
1569
|
+
this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
|
|
1570
|
+
(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
|
|
1611
1571
|
};
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
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);
|
|
1619
1579
|
context.calendarApi.unselect();
|
|
1620
1580
|
context.emitter.trigger('eventResizeStart', {
|
|
1621
1581
|
el: segEl,
|
|
@@ -1624,23 +1584,23 @@ var EventResizing = /** @class */ (function (_super) {
|
|
|
1624
1584
|
view: context.viewApi,
|
|
1625
1585
|
});
|
|
1626
1586
|
};
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
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 = {
|
|
1636
1596
|
affectedEvents: relevantEvents,
|
|
1637
1597
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1638
1598
|
isEvent: true,
|
|
1639
1599
|
};
|
|
1640
1600
|
if (hit) {
|
|
1641
|
-
|
|
1642
|
-
&&
|
|
1643
|
-
&& !
|
|
1601
|
+
let disallowed = hit.componentId === initialHit.componentId
|
|
1602
|
+
&& this.isHitComboAllowed
|
|
1603
|
+
&& !this.isHitComboAllowed(initialHit, hit);
|
|
1644
1604
|
if (!disallowed) {
|
|
1645
1605
|
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
|
|
1646
1606
|
}
|
|
@@ -1674,77 +1634,75 @@ var EventResizing = /** @class */ (function (_super) {
|
|
|
1674
1634
|
if (mutation && isHitsEqual(initialHit, hit)) {
|
|
1675
1635
|
mutation = null;
|
|
1676
1636
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1637
|
+
this.validMutation = mutation;
|
|
1638
|
+
this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
1679
1639
|
}
|
|
1680
1640
|
};
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
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;
|
|
1688
1648
|
context.emitter.trigger('eventResizeStop', {
|
|
1689
|
-
el:
|
|
1649
|
+
el: this.draggingSegEl,
|
|
1690
1650
|
event: eventApi,
|
|
1691
1651
|
jsEvent: ev.origEvent,
|
|
1692
1652
|
view: context.viewApi,
|
|
1693
1653
|
});
|
|
1694
|
-
if (
|
|
1695
|
-
|
|
1654
|
+
if (this.validMutation) {
|
|
1655
|
+
let updatedEventApi = new common.EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
1696
1656
|
context.dispatch({
|
|
1697
1657
|
type: 'MERGE_EVENTS',
|
|
1698
1658
|
eventStore: mutatedRelevantEvents,
|
|
1699
1659
|
});
|
|
1700
|
-
|
|
1660
|
+
let eventChangeArg = {
|
|
1701
1661
|
oldEvent: eventApi,
|
|
1702
1662
|
event: updatedEventApi,
|
|
1703
1663
|
relatedEvents: common.buildEventApis(mutatedRelevantEvents, context, eventInstance),
|
|
1704
|
-
revert
|
|
1664
|
+
revert() {
|
|
1705
1665
|
context.dispatch({
|
|
1706
1666
|
type: 'MERGE_EVENTS',
|
|
1707
1667
|
eventStore: relevantEvents, // the pre-change events
|
|
1708
1668
|
});
|
|
1709
1669
|
},
|
|
1710
1670
|
};
|
|
1711
|
-
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 }));
|
|
1712
1672
|
context.emitter.trigger('eventChange', eventChangeArg);
|
|
1713
1673
|
}
|
|
1714
1674
|
else {
|
|
1715
1675
|
context.emitter.trigger('_noEventResize');
|
|
1716
1676
|
}
|
|
1717
1677
|
// reset all internal state
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1678
|
+
this.draggingSeg = null;
|
|
1679
|
+
this.relevantEvents = null;
|
|
1680
|
+
this.validMutation = null;
|
|
1721
1681
|
// okay to keep eventInstance around. useful to set it in handlePointerDown
|
|
1722
1682
|
};
|
|
1723
|
-
|
|
1724
|
-
|
|
1683
|
+
let { component } = settings;
|
|
1684
|
+
let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
|
|
1725
1685
|
dragging.pointer.selector = '.fc-event-resizer';
|
|
1726
1686
|
dragging.touchScrollAllowed = false;
|
|
1727
1687
|
dragging.autoScroller.isEnabled = component.context.options.dragScroll;
|
|
1728
|
-
|
|
1729
|
-
hitDragging.emitter.on('pointerdown',
|
|
1730
|
-
hitDragging.emitter.on('dragstart',
|
|
1731
|
-
hitDragging.emitter.on('hitupdate',
|
|
1732
|
-
hitDragging.emitter.on('dragend',
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
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() {
|
|
1736
1695
|
this.dragging.destroy();
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1696
|
+
}
|
|
1697
|
+
querySegEl(ev) {
|
|
1739
1698
|
return common.elementClosest(ev.subjectEl, '.fc-event');
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
}(common.Interaction));
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1743
1701
|
function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
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);
|
|
1748
1706
|
if (isFromStart) {
|
|
1749
1707
|
if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
|
|
1750
1708
|
return { startDelta: delta };
|
|
@@ -1756,47 +1714,46 @@ function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
|
1756
1714
|
return null;
|
|
1757
1715
|
}
|
|
1758
1716
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
var _this = this;
|
|
1717
|
+
class UnselectAuto {
|
|
1718
|
+
constructor(context) {
|
|
1762
1719
|
this.context = context;
|
|
1763
1720
|
this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
|
|
1764
1721
|
this.matchesCancel = false;
|
|
1765
1722
|
this.matchesEvent = false;
|
|
1766
|
-
this.onSelect =
|
|
1723
|
+
this.onSelect = (selectInfo) => {
|
|
1767
1724
|
if (selectInfo.jsEvent) {
|
|
1768
|
-
|
|
1725
|
+
this.isRecentPointerDateSelect = true;
|
|
1769
1726
|
}
|
|
1770
1727
|
};
|
|
1771
|
-
this.onDocumentPointerDown =
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
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?
|
|
1776
1733
|
};
|
|
1777
|
-
this.onDocumentPointerUp =
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1734
|
+
this.onDocumentPointerUp = (pev) => {
|
|
1735
|
+
let { context } = this;
|
|
1736
|
+
let { documentPointer } = this;
|
|
1737
|
+
let calendarState = context.getCurrentData();
|
|
1781
1738
|
// touch-scrolling should never unfocus any type of selection
|
|
1782
1739
|
if (!documentPointer.wasTouchScroll) {
|
|
1783
1740
|
if (calendarState.dateSelection && // an existing date selection?
|
|
1784
|
-
!
|
|
1741
|
+
!this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
|
|
1785
1742
|
) {
|
|
1786
|
-
|
|
1787
|
-
if (unselectAuto && (!unselectAuto || !
|
|
1743
|
+
let unselectAuto = context.options.unselectAuto;
|
|
1744
|
+
if (unselectAuto && (!unselectAuto || !this.matchesCancel)) {
|
|
1788
1745
|
context.calendarApi.unselect(pev);
|
|
1789
1746
|
}
|
|
1790
1747
|
}
|
|
1791
1748
|
if (calendarState.eventSelection && // an existing event selected?
|
|
1792
|
-
!
|
|
1749
|
+
!this.matchesEvent // interaction DIDN'T start on an event
|
|
1793
1750
|
) {
|
|
1794
1751
|
context.dispatch({ type: 'UNSELECT_EVENT' });
|
|
1795
1752
|
}
|
|
1796
1753
|
}
|
|
1797
|
-
|
|
1754
|
+
this.isRecentPointerDateSelect = false;
|
|
1798
1755
|
};
|
|
1799
|
-
|
|
1756
|
+
let documentPointer = this.documentPointer = new PointerDragging(document);
|
|
1800
1757
|
documentPointer.shouldIgnoreMove = true;
|
|
1801
1758
|
documentPointer.shouldWatchScroll = false;
|
|
1802
1759
|
documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
|
|
@@ -1806,17 +1763,16 @@ var UnselectAuto = /** @class */ (function () {
|
|
|
1806
1763
|
*/
|
|
1807
1764
|
context.emitter.on('select', this.onSelect);
|
|
1808
1765
|
}
|
|
1809
|
-
|
|
1766
|
+
destroy() {
|
|
1810
1767
|
this.context.emitter.off('select', this.onSelect);
|
|
1811
1768
|
this.documentPointer.destroy();
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
}());
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1815
1771
|
|
|
1816
|
-
|
|
1772
|
+
const OPTION_REFINERS = {
|
|
1817
1773
|
fixedMirrorParent: common.identity,
|
|
1818
1774
|
};
|
|
1819
|
-
|
|
1775
|
+
const LISTENER_REFINERS = {
|
|
1820
1776
|
dateClick: common.identity,
|
|
1821
1777
|
eventDragStart: common.identity,
|
|
1822
1778
|
eventDragStop: common.identity,
|
|
@@ -1834,30 +1790,29 @@ Given an already instantiated draggable object for one-or-more elements,
|
|
|
1834
1790
|
Interprets any dragging as an attempt to drag an events that lives outside
|
|
1835
1791
|
of a calendar onto a calendar.
|
|
1836
1792
|
*/
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
var _this = this;
|
|
1793
|
+
class ExternalElementDragging {
|
|
1794
|
+
constructor(dragging, suppliedDragMeta) {
|
|
1840
1795
|
this.receivingContext = null;
|
|
1841
1796
|
this.droppableEvent = null; // will exist for all drags, even if create:false
|
|
1842
1797
|
this.suppliedDragMeta = null;
|
|
1843
1798
|
this.dragMeta = null;
|
|
1844
|
-
this.handleDragStart =
|
|
1845
|
-
|
|
1799
|
+
this.handleDragStart = (ev) => {
|
|
1800
|
+
this.dragMeta = this.buildDragMeta(ev.subjectEl);
|
|
1846
1801
|
};
|
|
1847
|
-
this.handleHitUpdate =
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
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 = {
|
|
1853
1808
|
affectedEvents: common.createEmptyEventStore(),
|
|
1854
1809
|
mutatedEvents: common.createEmptyEventStore(),
|
|
1855
|
-
isEvent:
|
|
1810
|
+
isEvent: this.dragMeta.create,
|
|
1856
1811
|
};
|
|
1857
1812
|
if (hit) {
|
|
1858
1813
|
receivingContext = hit.context;
|
|
1859
|
-
if (
|
|
1860
|
-
droppableEvent = computeEventForDateSpan(hit.dateSpan,
|
|
1814
|
+
if (this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
|
|
1815
|
+
droppableEvent = computeEventForDateSpan(hit.dateSpan, this.dragMeta, receivingContext);
|
|
1861
1816
|
interaction.mutatedEvents = common.eventTupleToStore(droppableEvent);
|
|
1862
1817
|
isInvalid = !common.isInteractionValid(interaction, hit.dateProfile, receivingContext);
|
|
1863
1818
|
if (isInvalid) {
|
|
@@ -1866,7 +1821,7 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1866
1821
|
}
|
|
1867
1822
|
}
|
|
1868
1823
|
}
|
|
1869
|
-
|
|
1824
|
+
this.displayDrag(receivingContext, interaction);
|
|
1870
1825
|
// show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
|
|
1871
1826
|
// TODO: wish we could somehow wait for dispatch to guarantee render
|
|
1872
1827
|
dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
|
|
@@ -1878,23 +1833,23 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1878
1833
|
}
|
|
1879
1834
|
if (!isFinal) {
|
|
1880
1835
|
dragging.setMirrorNeedsRevert(!droppableEvent);
|
|
1881
|
-
|
|
1882
|
-
|
|
1836
|
+
this.receivingContext = receivingContext;
|
|
1837
|
+
this.droppableEvent = droppableEvent;
|
|
1883
1838
|
}
|
|
1884
1839
|
};
|
|
1885
|
-
this.handleDragEnd =
|
|
1886
|
-
|
|
1887
|
-
|
|
1840
|
+
this.handleDragEnd = (pev) => {
|
|
1841
|
+
let { receivingContext, droppableEvent } = this;
|
|
1842
|
+
this.clearDrag();
|
|
1888
1843
|
if (receivingContext && droppableEvent) {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
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 }));
|
|
1893
1848
|
if (dragMeta.create) {
|
|
1894
|
-
|
|
1849
|
+
let addingEvents = common.eventTupleToStore(droppableEvent);
|
|
1895
1850
|
receivingContext.dispatch({
|
|
1896
1851
|
type: 'MERGE_EVENTS',
|
|
1897
|
-
eventStore:
|
|
1852
|
+
eventStore: addingEvents,
|
|
1898
1853
|
});
|
|
1899
1854
|
if (pev.isTouch) {
|
|
1900
1855
|
receivingContext.dispatch({
|
|
@@ -1906,10 +1861,10 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1906
1861
|
receivingContext.emitter.trigger('eventReceive', {
|
|
1907
1862
|
event: new common.EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
|
|
1908
1863
|
relatedEvents: [],
|
|
1909
|
-
revert
|
|
1864
|
+
revert() {
|
|
1910
1865
|
receivingContext.dispatch({
|
|
1911
1866
|
type: 'REMOVE_EVENTS',
|
|
1912
|
-
eventStore:
|
|
1867
|
+
eventStore: addingEvents,
|
|
1913
1868
|
});
|
|
1914
1869
|
},
|
|
1915
1870
|
draggedEl: pev.subjectEl,
|
|
@@ -1917,17 +1872,17 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1917
1872
|
});
|
|
1918
1873
|
}
|
|
1919
1874
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1875
|
+
this.receivingContext = null;
|
|
1876
|
+
this.droppableEvent = null;
|
|
1922
1877
|
};
|
|
1923
|
-
|
|
1878
|
+
let hitDragging = this.hitDragging = new HitDragging(dragging, common.interactionSettingsStore);
|
|
1924
1879
|
hitDragging.requireInitial = false; // will start outside of a component
|
|
1925
1880
|
hitDragging.emitter.on('dragstart', this.handleDragStart);
|
|
1926
1881
|
hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
|
|
1927
1882
|
hitDragging.emitter.on('dragend', this.handleDragEnd);
|
|
1928
1883
|
this.suppliedDragMeta = suppliedDragMeta;
|
|
1929
1884
|
}
|
|
1930
|
-
|
|
1885
|
+
buildDragMeta(subjectEl) {
|
|
1931
1886
|
if (typeof this.suppliedDragMeta === 'object') {
|
|
1932
1887
|
return common.parseDragMeta(this.suppliedDragMeta);
|
|
1933
1888
|
}
|
|
@@ -1935,23 +1890,23 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1935
1890
|
return common.parseDragMeta(this.suppliedDragMeta(subjectEl));
|
|
1936
1891
|
}
|
|
1937
1892
|
return getDragMetaFromEl(subjectEl);
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1893
|
+
}
|
|
1894
|
+
displayDrag(nextContext, state) {
|
|
1895
|
+
let prevContext = this.receivingContext;
|
|
1941
1896
|
if (prevContext && prevContext !== nextContext) {
|
|
1942
1897
|
prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1943
1898
|
}
|
|
1944
1899
|
if (nextContext) {
|
|
1945
|
-
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state
|
|
1900
|
+
nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
|
|
1946
1901
|
}
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1902
|
+
}
|
|
1903
|
+
clearDrag() {
|
|
1949
1904
|
if (this.receivingContext) {
|
|
1950
1905
|
this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
|
|
1951
1906
|
}
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1907
|
+
}
|
|
1908
|
+
canDropElOnCalendar(el, receivingContext) {
|
|
1909
|
+
let dropAccept = receivingContext.options.dropAccept;
|
|
1955
1910
|
if (typeof dropAccept === 'function') {
|
|
1956
1911
|
return dropAccept.call(receivingContext.calendarApi, el);
|
|
1957
1912
|
}
|
|
@@ -1959,45 +1914,43 @@ var ExternalElementDragging = /** @class */ (function () {
|
|
|
1959
1914
|
return Boolean(common.elementMatches(el, dropAccept));
|
|
1960
1915
|
}
|
|
1961
1916
|
return true;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
}());
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1965
1919
|
// Utils for computing event store from the DragMeta
|
|
1966
1920
|
// ----------------------------------------------------------------------------------------------------
|
|
1967
1921
|
function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
1968
|
-
|
|
1969
|
-
for (
|
|
1970
|
-
var transform = _a[_i];
|
|
1922
|
+
let defProps = Object.assign({}, dragMeta.leftoverProps);
|
|
1923
|
+
for (let transform of context.pluginHooks.externalDefTransforms) {
|
|
1971
1924
|
tslib.__assign(defProps, transform(dateSpan, dragMeta));
|
|
1972
1925
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
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
|
|
1975
1928
|
context);
|
|
1976
|
-
|
|
1929
|
+
let start = dateSpan.range.start;
|
|
1977
1930
|
// only rely on time info if drop zone is all-day,
|
|
1978
1931
|
// otherwise, we already know the time
|
|
1979
1932
|
if (dateSpan.allDay && dragMeta.startTime) {
|
|
1980
1933
|
start = context.dateEnv.add(start, dragMeta.startTime);
|
|
1981
1934
|
}
|
|
1982
|
-
|
|
1935
|
+
let end = dragMeta.duration ?
|
|
1983
1936
|
context.dateEnv.add(start, dragMeta.duration) :
|
|
1984
1937
|
common.getDefaultEventEnd(dateSpan.allDay, start, context);
|
|
1985
|
-
|
|
1986
|
-
return { def
|
|
1938
|
+
let instance = common.createEventInstance(def.defId, { start, end });
|
|
1939
|
+
return { def, instance };
|
|
1987
1940
|
}
|
|
1988
1941
|
// Utils for extracting data from element
|
|
1989
1942
|
// ----------------------------------------------------------------------------------------------------
|
|
1990
1943
|
function getDragMetaFromEl(el) {
|
|
1991
|
-
|
|
1992
|
-
|
|
1944
|
+
let str = getEmbeddedElData(el, 'event');
|
|
1945
|
+
let obj = str ?
|
|
1993
1946
|
JSON.parse(str) :
|
|
1994
1947
|
{ create: false }; // if no embedded data, assume no event creation
|
|
1995
1948
|
return common.parseDragMeta(obj);
|
|
1996
1949
|
}
|
|
1997
1950
|
common.config.dataAttrPrefix = '';
|
|
1998
1951
|
function getEmbeddedElData(el, name) {
|
|
1999
|
-
|
|
2000
|
-
|
|
1952
|
+
let prefix = common.config.dataAttrPrefix;
|
|
1953
|
+
let prefixedName = (prefix ? prefix + '-' : '') + name;
|
|
2001
1954
|
return el.getAttribute('data-' + prefixedName) || '';
|
|
2002
1955
|
}
|
|
2003
1956
|
|
|
@@ -2006,13 +1959,11 @@ Makes an element (that is *external* to any calendar) draggable.
|
|
|
2006
1959
|
Can pass in data that determines how an event will be created when dropped onto a calendar.
|
|
2007
1960
|
Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
|
|
2008
1961
|
*/
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
var dragging = _this.dragging;
|
|
2015
|
-
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;
|
|
2016
1967
|
dragging.minDistance =
|
|
2017
1968
|
minDistance != null ?
|
|
2018
1969
|
minDistance :
|
|
@@ -2022,15 +1973,15 @@ var ExternalDraggable = /** @class */ (function () {
|
|
|
2022
1973
|
(longPressDelay != null ? longPressDelay : common.BASE_OPTION_DEFAULTS.longPressDelay) :
|
|
2023
1974
|
0;
|
|
2024
1975
|
};
|
|
2025
|
-
this.handleDragStart =
|
|
1976
|
+
this.handleDragStart = (ev) => {
|
|
2026
1977
|
if (ev.isTouch &&
|
|
2027
|
-
|
|
1978
|
+
this.dragging.delay &&
|
|
2028
1979
|
ev.subjectEl.classList.contains('fc-event')) {
|
|
2029
|
-
|
|
1980
|
+
this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
|
|
2030
1981
|
}
|
|
2031
1982
|
};
|
|
2032
1983
|
this.settings = settings;
|
|
2033
|
-
|
|
1984
|
+
let dragging = this.dragging = new FeaturefulElementDragging(el);
|
|
2034
1985
|
dragging.touchScrollAllowed = false;
|
|
2035
1986
|
if (settings.itemSelector != null) {
|
|
2036
1987
|
dragging.pointer.selector = settings.itemSelector;
|
|
@@ -2042,11 +1993,10 @@ var ExternalDraggable = /** @class */ (function () {
|
|
|
2042
1993
|
dragging.emitter.on('dragstart', this.handleDragStart);
|
|
2043
1994
|
new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
|
|
2044
1995
|
}
|
|
2045
|
-
|
|
1996
|
+
destroy() {
|
|
2046
1997
|
this.dragging.destroy();
|
|
2047
|
-
}
|
|
2048
|
-
|
|
2049
|
-
}());
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2050
2000
|
|
|
2051
2001
|
/*
|
|
2052
2002
|
Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
|
|
@@ -2054,45 +2004,43 @@ The third-party system is responsible for drawing the visuals effects of the dra
|
|
|
2054
2004
|
This class simply monitors for pointer movements and fires events.
|
|
2055
2005
|
It also has the ability to hide the moving element (the "mirror") during the drag.
|
|
2056
2006
|
*/
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
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) {
|
|
2067
2016
|
// fire dragstart right away. does not support delay or min-distance
|
|
2068
|
-
|
|
2017
|
+
this.emitter.trigger('dragstart', ev);
|
|
2069
2018
|
}
|
|
2070
2019
|
};
|
|
2071
|
-
|
|
2072
|
-
if (!
|
|
2073
|
-
|
|
2020
|
+
this.handlePointerMove = (ev) => {
|
|
2021
|
+
if (!this.shouldIgnoreMove) {
|
|
2022
|
+
this.emitter.trigger('dragmove', ev);
|
|
2074
2023
|
}
|
|
2075
2024
|
};
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
if (!
|
|
2025
|
+
this.handlePointerUp = (ev) => {
|
|
2026
|
+
this.emitter.trigger('pointerup', ev);
|
|
2027
|
+
if (!this.shouldIgnoreMove) {
|
|
2079
2028
|
// fire dragend right away. does not support a revert animation
|
|
2080
|
-
|
|
2029
|
+
this.emitter.trigger('dragend', ev);
|
|
2081
2030
|
}
|
|
2082
2031
|
};
|
|
2083
|
-
|
|
2084
|
-
pointer.emitter.on('pointerdown',
|
|
2085
|
-
pointer.emitter.on('pointermove',
|
|
2086
|
-
pointer.emitter.on('pointerup',
|
|
2087
|
-
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);
|
|
2088
2036
|
}
|
|
2089
|
-
|
|
2037
|
+
destroy() {
|
|
2090
2038
|
this.pointer.destroy();
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2039
|
+
}
|
|
2040
|
+
setIgnoreMove(bool) {
|
|
2093
2041
|
this.shouldIgnoreMove = bool;
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2042
|
+
}
|
|
2043
|
+
setMirrorIsVisible(bool) {
|
|
2096
2044
|
if (bool) {
|
|
2097
2045
|
// restore a previously hidden element.
|
|
2098
2046
|
// use the reference in case the selector class has already been removed.
|
|
@@ -2102,7 +2050,7 @@ var InferredElementDragging = /** @class */ (function (_super) {
|
|
|
2102
2050
|
}
|
|
2103
2051
|
}
|
|
2104
2052
|
else {
|
|
2105
|
-
|
|
2053
|
+
let mirrorEl = this.mirrorSelector
|
|
2106
2054
|
// TODO: somehow query FullCalendars WITHIN shadow-roots
|
|
2107
2055
|
? document.querySelector(this.mirrorSelector)
|
|
2108
2056
|
: null;
|
|
@@ -2111,17 +2059,16 @@ var InferredElementDragging = /** @class */ (function (_super) {
|
|
|
2111
2059
|
mirrorEl.style.visibility = 'hidden';
|
|
2112
2060
|
}
|
|
2113
2061
|
}
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
}(common.ElementDragging));
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2117
2064
|
|
|
2118
2065
|
/*
|
|
2119
2066
|
Bridges third-party drag-n-drop systems with FullCalendar.
|
|
2120
2067
|
Must be instantiated and destroyed by caller.
|
|
2121
2068
|
*/
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2069
|
+
class ThirdPartyDraggable {
|
|
2070
|
+
constructor(containerOrSettings, settings) {
|
|
2071
|
+
let containerEl = document;
|
|
2125
2072
|
if (
|
|
2126
2073
|
// wish we could just test instanceof EventTarget, but doesn't work in IE11
|
|
2127
2074
|
containerOrSettings === document ||
|
|
@@ -2132,7 +2079,7 @@ var ThirdPartyDraggable = /** @class */ (function () {
|
|
|
2132
2079
|
else {
|
|
2133
2080
|
settings = (containerOrSettings || {});
|
|
2134
2081
|
}
|
|
2135
|
-
|
|
2082
|
+
let dragging = this.dragging = new InferredElementDragging(containerEl);
|
|
2136
2083
|
if (typeof settings.itemSelector === 'string') {
|
|
2137
2084
|
dragging.pointer.selector = settings.itemSelector;
|
|
2138
2085
|
}
|
|
@@ -2144,11 +2091,10 @@ var ThirdPartyDraggable = /** @class */ (function () {
|
|
|
2144
2091
|
}
|
|
2145
2092
|
new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
|
|
2146
2093
|
}
|
|
2147
|
-
|
|
2094
|
+
destroy() {
|
|
2148
2095
|
this.dragging.destroy();
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
}());
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2152
2098
|
|
|
2153
2099
|
var main = common.createPlugin({
|
|
2154
2100
|
componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
|