暂无描述

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