暂无描述

main.esm.js 92KB

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