@event-calendar/core 4.7.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +29 -51
  2. package/dist/index.css +627 -731
  3. package/dist/index.js +2500 -3191
  4. package/package.json +2 -2
  5. package/src/Auxiliary.svelte +2 -13
  6. package/src/Buttons.svelte +62 -52
  7. package/src/Calendar.svelte +9 -3
  8. package/src/lib/a11y.js +2 -2
  9. package/src/lib/attachments.js +61 -0
  10. package/src/lib/chunks.js +117 -0
  11. package/src/lib/components/BaseDay.svelte +50 -0
  12. package/src/lib/components/BaseEvent.svelte +3 -3
  13. package/src/lib/components/ColHead.svelte +34 -0
  14. package/src/lib/components/DayHeader.svelte +14 -0
  15. package/src/lib/components/InteractableEvent.svelte +1 -3
  16. package/src/lib/components/index.js +3 -0
  17. package/src/lib/date.js +1 -1
  18. package/src/lib/dom.js +0 -4
  19. package/src/lib/events.js +10 -134
  20. package/src/lib/index.js +3 -2
  21. package/src/lib/{times.js → slots.js} +14 -19
  22. package/src/lib/stores.js +0 -33
  23. package/src/lib/utils.js +11 -2
  24. package/src/lib/view.js +0 -4
  25. package/src/plugins/day-grid/Day.svelte +36 -129
  26. package/src/plugins/day-grid/Event.svelte +42 -41
  27. package/src/plugins/day-grid/Popup.svelte +65 -48
  28. package/src/plugins/day-grid/View.svelte +76 -4
  29. package/src/plugins/day-grid/index.js +5 -5
  30. package/src/plugins/day-grid/lib.js +61 -0
  31. package/src/plugins/day-grid/stores.js +2 -20
  32. package/src/plugins/interaction/Action.svelte +40 -45
  33. package/src/plugins/interaction/Auxiliary.svelte +4 -4
  34. package/src/plugins/interaction/Pointer.svelte +8 -12
  35. package/src/plugins/interaction/Resizer.svelte +2 -2
  36. package/src/plugins/interaction/lib/utils.js +1 -5
  37. package/src/plugins/list/Day.svelte +8 -24
  38. package/src/plugins/list/View.svelte +39 -2
  39. package/src/plugins/resource-time-grid/Label.svelte +2 -2
  40. package/src/plugins/resource-time-grid/View.svelte +38 -82
  41. package/src/plugins/resource-time-grid/index.js +18 -10
  42. package/src/plugins/resource-time-grid/lib.js +31 -0
  43. package/src/plugins/resource-time-grid/options.js +10 -0
  44. package/src/plugins/resource-time-grid/stores.js +34 -0
  45. package/src/plugins/resource-timeline/Day.svelte +10 -73
  46. package/src/plugins/resource-timeline/Event.svelte +14 -23
  47. package/src/plugins/resource-timeline/Header.svelte +5 -5
  48. package/src/plugins/resource-timeline/Label.svelte +4 -12
  49. package/src/plugins/resource-timeline/NowIndicator.svelte +33 -28
  50. package/src/plugins/resource-timeline/View.svelte +129 -14
  51. package/src/plugins/resource-timeline/index.js +26 -23
  52. package/src/plugins/resource-timeline/lib.js +115 -118
  53. package/src/plugins/resource-timeline/stores.js +11 -7
  54. package/src/plugins/time-grid/AllDayEvent.svelte +31 -0
  55. package/src/plugins/time-grid/Day.svelte +11 -99
  56. package/src/plugins/time-grid/Event.svelte +18 -20
  57. package/src/plugins/time-grid/NowIndicator.svelte +32 -10
  58. package/src/plugins/time-grid/View.svelte +127 -35
  59. package/src/plugins/time-grid/index.js +10 -8
  60. package/src/plugins/time-grid/lib.js +142 -0
  61. package/src/plugins/time-grid/options.js +57 -0
  62. package/src/plugins/time-grid/stores.js +41 -8
  63. package/src/storage/options.js +4 -39
  64. package/src/storage/state.js +1 -4
  65. package/src/storage/stores.js +42 -11
  66. package/src/styles/days.css +91 -0
  67. package/src/styles/events.css +180 -0
  68. package/src/styles/index.css +126 -0
  69. package/src/styles/now-indicator.css +35 -0
  70. package/src/styles/popup.css +30 -0
  71. package/src/styles/sidebar.css +59 -0
  72. package/src/styles/slots.css +42 -0
  73. package/src/styles/theme.css +68 -0
  74. package/src/styles/toolbar.css +80 -0
  75. package/src/lib/actions.js +0 -52
  76. package/src/plugins/day-grid/Body.svelte +0 -54
  77. package/src/plugins/day-grid/Header.svelte +0 -20
  78. package/src/plugins/day-grid/Week.svelte +0 -60
  79. package/src/plugins/list/Body.svelte +0 -44
  80. package/src/plugins/resource-timeline/Body.svelte +0 -67
  81. package/src/plugins/resource-timeline/Days.svelte +0 -72
  82. package/src/plugins/resource-timeline/Sidebar.svelte +0 -35
  83. package/src/plugins/time-grid/Body.svelte +0 -43
  84. package/src/plugins/time-grid/Section.svelte +0 -29
  85. package/src/plugins/time-grid/all-day/Day.svelte +0 -65
  86. package/src/plugins/time-grid/all-day/Event.svelte +0 -37
  87. package/src/plugins/time-grid/all-day/Week.svelte +0 -65
  88. package/src/plugins/time-grid/utils.js +0 -58
  89. package/src/styles/day-grid.scss +0 -51
  90. package/src/styles/index.scss +0 -553
  91. package/src/styles/theme.scss +0 -95
  92. package/src/styles/time-grid.scss +0 -83
  93. package/src/styles/timeline.scss +0 -152
@@ -1,69 +1,82 @@
1
1
  <script>
2
- import {getContext, tick, untrack} from 'svelte';
3
- import {ancestor, rect, setContent, outsideEvent, keyEnter, toISOString, stopPropagation} from '#lib';
2
+ import {getContext, onMount, untrack} from 'svelte';
3
+ import {
4
+ assign, contentFrom, createEventChunk, outsideEvent, keyEnter, rect, stopPropagation, toISOString
5
+ } from '#lib';
4
6
  import Event from './Event.svelte';
5
7
 
6
- let {buttonText, theme, _interaction, _intlDayPopover, _popupDate, _popupChunks} = getContext('state');
8
+ let {gridEl, chunks} = $props();
9
+
10
+ let {_colsCount, _interaction, _intlDayPopover, _popupDay, buttonText, theme} = getContext('state');
7
11
 
8
12
  let el = $state();
9
13
  let style = $state('');
10
14
 
15
+ let {gridColumn, gridRow, dayStart, dayEnd} = $derived($_popupDay);
16
+
17
+ let popupChunks = $derived.by(() => {
18
+ let result = [];
19
+ for (let chunk of chunks) {
20
+ if (chunk.gridRow === gridRow && chunk.gridColumn <= gridColumn && chunk.gridColumn + chunk.dates.length > gridColumn) {
21
+ result.push(assign({}, chunk, createEventChunk(chunk.event, dayStart, dayEnd)));
22
+ }
23
+ }
24
+ result.sort((a, b) => a.top - b.top);
25
+ return result;
26
+ });
27
+
28
+ onMount(() => {
29
+ el.show();
30
+ });
31
+
32
+ $effect(() => {
33
+ if (popupChunks.length) {
34
+ untrack(position);
35
+ } else {
36
+ close();
37
+ }
38
+ });
39
+
11
40
  function position() {
12
- let dayEl = ancestor(el, 1);
13
- let bodyEl = ancestor(dayEl, 3);
41
+ let dayEl = gridEl.children.item((gridRow - 1) * $_colsCount + gridColumn - 1);
14
42
  let popupRect = rect(el);
15
43
  let dayRect = rect(dayEl);
16
- let bodyRect = rect(bodyEl);
44
+ let gridRect = rect(gridEl);
17
45
  style = '';
18
46
 
19
47
  let left;
20
- if (popupRect.width >= bodyRect.width) {
21
- left = bodyRect.left - dayRect.left;
22
- let right = dayRect.right - bodyRect.right;
23
- style += `right:${right}px;`;
48
+ if (popupRect.width >= gridRect.width) {
49
+ left = gridRect.left - dayRect.left;
50
+ let right = dayRect.right - gridRect.right;
51
+ style += `inset-inline-end:${right}px;`;
24
52
  } else {
25
53
  left = (dayRect.width - popupRect.width) / 2;
26
- if (dayRect.left + left < bodyRect.left) {
27
- left = bodyRect.left - dayRect.left;
28
- } else if (dayRect.left + left + popupRect.width > bodyRect.right) {
29
- left = bodyRect.right - dayRect.left - popupRect.width;
54
+ if (dayRect.left + left < gridRect.left) {
55
+ left = gridRect.left - dayRect.left;
56
+ } else if (dayRect.left + left + popupRect.width > gridRect.right) {
57
+ left = gridRect.right - dayRect.left - popupRect.width;
30
58
  }
31
59
  }
32
- style += `left:${left}px;`;
60
+ style += `inset-inline-start:${left}px;`;
33
61
 
34
62
  let top;
35
- if (popupRect.height >= bodyRect.height) {
36
- top = bodyRect.top - dayRect.top;
37
- let bottom = dayRect.bottom - bodyRect.bottom;
38
- style += `bottom:${bottom}px;`;
63
+ if (popupRect.height >= gridRect.height) {
64
+ top = gridRect.top - dayRect.top;
65
+ let bottom = dayRect.bottom - gridRect.bottom;
66
+ style += `inset-block-end:${bottom}px;`;
39
67
  } else {
40
68
  top = (dayRect.height - popupRect.height) / 2;
41
- if (dayRect.top + top < bodyRect.top) {
42
- top = bodyRect.top - dayRect.top;
43
- } else if (dayRect.top + top + popupRect.height > bodyRect.bottom) {
44
- top = bodyRect.bottom - dayRect.top - popupRect.height;
69
+ if (dayRect.top + top < gridRect.top) {
70
+ top = gridRect.top - dayRect.top;
71
+ } else if (dayRect.top + top + popupRect.height > gridRect.bottom) {
72
+ top = gridRect.bottom - dayRect.top - popupRect.height;
45
73
  }
46
74
  }
47
- style += `top:${top}px;`;
48
- }
49
-
50
- $effect(() => {
51
- // Fire reposition only on popup chunks change
52
- $_popupChunks;
53
- // Let chunks to update/mount then position the popup
54
- tick().then(reposition);
55
- });
56
- function reposition() {
57
- if ($_popupChunks.length) {
58
- position();
59
- } else {
60
- close();
61
- }
75
+ style += `inset-block-start:${top}px;`;
62
76
  }
63
77
 
64
78
  function close() {
65
- $_popupDate = null;
66
- $_popupChunks = [];
79
+ $_popupDay = null;
67
80
  }
68
81
 
69
82
  function handlePointerDownOutside() {
@@ -72,28 +85,32 @@
72
85
  }
73
86
  </script>
74
87
 
75
- <div
88
+ <dialog
76
89
  bind:this={el}
77
90
  class="{$theme.popup}"
91
+ closedby="closerequest"
78
92
  {style}
79
- use:outsideEvent={'pointerdown'}
80
- onpointerdown={stopPropagation()}
93
+ style:grid-area="{`${gridRow + 1} / ${gridColumn}`}"
94
+ {@attach outsideEvent('pointerdown')}
81
95
  onpointerdownoutside={handlePointerDownOutside}
96
+ onclose={close}
82
97
  >
83
- <div class="{$theme.dayHead}">
84
- <time datetime="{toISOString($_popupDate, 10)}" use:setContent={$_intlDayPopover.format($_popupDate)}></time>
98
+ <header class="{$theme.dayHead}">
99
+ <time datetime="{toISOString(dayStart, 10)}" {@attach contentFrom($_intlDayPopover.format(dayStart))}></time>
85
100
  <!-- svelte-ignore a11y_missing_attribute -->
101
+ <!-- svelte-ignore a11y_autofocus -->
86
102
  <a
103
+ autofocus
87
104
  role="button"
88
105
  tabindex="0"
89
106
  aria-label={$buttonText.close}
90
107
  onclick={stopPropagation(close)}
91
108
  onkeydown={keyEnter(close)}
92
109
  >&times;</a>
93
- </div>
110
+ </header>
94
111
  <div class="{$theme.events}">
95
- {#each $_popupChunks as chunk (chunk.event)}
112
+ {#each popupChunks as chunk}
96
113
  <Event {chunk} inPopup />
97
114
  {/each}
98
115
  </div>
99
- </div>
116
+ </dialog>
@@ -1,7 +1,79 @@
1
1
  <script>
2
- import Header from './Header.svelte';
3
- import Body from './Body.svelte';
2
+ import {getContext} from 'svelte';
3
+ import {contentFrom, resizeObserver, runReposition} from '#lib';
4
+ import Day from './Day.svelte';
5
+ import Event from './Event.svelte';
6
+ import Popup from './Popup.svelte';
7
+ import {createEventChunks, createIEventChunks, createGrid} from './lib.js';
8
+
9
+ let {_mainEl, _colsCount, _filteredEvents, _hiddenChunks, _iEvents, _intlDayHeader, _intlDayHeaderAL, _popupDay,
10
+ _viewDates, dayMaxEvents, highlightedDates, theme, validRange} = getContext('state');
11
+
12
+ let gridEl = $state();
13
+ let grid = $derived(createGrid($_viewDates, $_colsCount, $validRange, $highlightedDates));
14
+ let {chunks, bgChunks} = $derived(createEventChunks($_filteredEvents, grid));
15
+ let iChunks = $derived(createIEventChunks($_iEvents, grid));
16
+
17
+ // Events reposition
18
+ let refs = [];
19
+ function reposition() {
20
+ $_hiddenChunks = {};
21
+ runReposition(refs, chunks);
22
+ }
23
+ $effect(reposition);
24
+ $effect(() => {
25
+ $_hiddenChunks;
26
+ refs.forEach(ref => ref.hide());
27
+ });
4
28
  </script>
5
29
 
6
- <Header/>
7
- <Body/>
30
+ <section
31
+ bind:this={$_mainEl}
32
+ class={[$theme.main, $dayMaxEvents === true && $theme.uniform]}
33
+ style:--ec-grid-cols="{grid[0].length}"
34
+ style:--ec-grid-rows="{grid.length}"
35
+ {@attach resizeObserver(reposition)}
36
+ >
37
+ <header class="{$theme.header}">
38
+ <div class="{$theme.grid}" role="row">
39
+ {#each grid[0] as {dayStart}, i}
40
+ <div
41
+ class={[$theme.colHead, $theme.weekdays?.[dayStart.getUTCDay()]]}
42
+ role="columnheader"
43
+ aria-colindex="{1 + i}"
44
+ >
45
+ <span
46
+ aria-label="{$_intlDayHeaderAL.format(dayStart)}"
47
+ {@attach contentFrom($_intlDayHeader.format(dayStart))}
48
+ ></span>
49
+ </div>
50
+ {/each}
51
+ </div>
52
+ </header>
53
+
54
+ <div class="{$theme.body}">
55
+ <div bind:this={gridEl} class="{$theme.grid}">
56
+ {#each grid as days}
57
+ {#each days as day}
58
+ <Day {day}/>
59
+ {/each}
60
+ {/each}
61
+ </div>
62
+ <div class="{$theme.events}">
63
+ {#each chunks as chunk, i}
64
+ <!-- svelte-ignore binding_property_non_reactive -->
65
+ <Event bind:this={refs[i]} {chunk} {gridEl}/>
66
+ {/each}
67
+ {#each bgChunks as chunk}
68
+ <Event {chunk}/>
69
+ {/each}
70
+ {#each iChunks as chunk}
71
+ <Event {chunk} {gridEl}/>
72
+ {/each}
73
+ </div>
74
+ </div>
75
+
76
+ {#if $_popupDay}
77
+ <Popup {gridEl} {chunks}/>
78
+ {/if}
79
+ </section>
@@ -1,6 +1,6 @@
1
1
  import {writable} from 'svelte/store';
2
2
  import {btnTextMonth, intl, themeView} from '#lib';
3
- import {days} from './stores.js';
3
+ import {colsCount} from './stores.js';
4
4
  import View from './View.svelte';
5
5
 
6
6
  export default {
@@ -16,6 +16,7 @@ export default {
16
16
  options.buttonText.close = 'Close';
17
17
  options.theme.uniform = 'ec-uniform';
18
18
  options.theme.dayFoot = 'ec-day-foot';
19
+ options.theme.otherMonth = 'ec-other-month';
19
20
  options.theme.popup = 'ec-popup';
20
21
  options.theme.weekNumber = 'ec-week-number';
21
22
  options.view = 'dayGridMonth';
@@ -32,11 +33,10 @@ export default {
32
33
  },
33
34
 
34
35
  createStores(state) {
35
- state._days = days(state);
36
+ state._colsCount = colsCount(state);
36
37
  state._intlDayCell = intl(state.locale, state.dayCellFormat);
37
38
  state._intlDayPopover = intl(state.locale, state.dayPopoverFormat);
38
- state._hiddenEvents = writable({});
39
- state._popupDate = writable(null);
40
- state._popupChunks = writable([]);
39
+ state._hiddenChunks = writable({});
40
+ state._popupDay = writable(null);
41
41
  }
42
42
  }
@@ -0,0 +1,61 @@
1
+ import {addDay, bgEvent, cloneDate, createAllDayChunks, datesEqual, outsideRange, prepareAllDayChunks} from '#lib';
2
+
3
+ export function createGrid($_viewDates, $_colsCount, $validRange, $highlightedDates) {
4
+ let grid = [];
5
+ let days = [];
6
+ let gridColumn = 1;
7
+ let gridRow = 1;
8
+ for (let date of $_viewDates) {
9
+ days.push({
10
+ gridColumn,
11
+ gridRow,
12
+ resource: undefined,
13
+ dayStart: date,
14
+ dayEnd: addDay(cloneDate(date)),
15
+ disabled: outsideRange(date, $validRange),
16
+ highlight: $highlightedDates.some(d => datesEqual(d, date))
17
+ });
18
+ if (gridColumn === $_colsCount) {
19
+ grid.push(days);
20
+ days = [];
21
+ gridColumn = 0;
22
+ ++ gridRow;
23
+ }
24
+ ++ gridColumn;
25
+ }
26
+
27
+ return grid;
28
+ }
29
+
30
+ export function createEventChunks($_filteredEvents, grid) {
31
+ let chunks = [];
32
+ let bgChunks = [];
33
+ for (let event of $_filteredEvents) {
34
+ for (let days of grid) {
35
+ if (bgEvent(event.display)) {
36
+ if (event.allDay) {
37
+ bgChunks = bgChunks.concat(createAllDayChunks(event, days));
38
+ }
39
+ } else {
40
+ chunks = chunks.concat(createAllDayChunks(event, days));
41
+ }
42
+ }
43
+ }
44
+ prepareAllDayChunks(chunks);
45
+
46
+ return {chunks, bgChunks};
47
+ }
48
+
49
+ export function createIEventChunks($_iEvents, grid) {
50
+ let iChunks = [];
51
+ for (let event of $_iEvents) {
52
+ if (!event) {
53
+ continue;
54
+ }
55
+ for (let days of grid) {
56
+ iChunks = iChunks.concat(createAllDayChunks(event, days));
57
+ }
58
+ }
59
+
60
+ return iChunks;
61
+ }
@@ -1,23 +1,5 @@
1
1
  import {derived} from 'svelte/store';
2
- import {cloneDate, addDay, subtractDay} from '#lib';
3
2
 
4
- export function days(state) {
5
- return derived([state.date, state.firstDay, state.hiddenDays], ([$date, $firstDay, $hiddenDays]) => {
6
- let days = [];
7
- let day = cloneDate($date);
8
- let max = 7;
9
- // First day of week
10
- while (day.getUTCDay() !== $firstDay && max) {
11
- subtractDay(day);
12
- --max;
13
- }
14
- for (let i = 0; i < 7; ++i) {
15
- if (!$hiddenDays.includes(day.getUTCDay())) {
16
- days.push(cloneDate(day));
17
- }
18
- addDay(day);
19
- }
20
-
21
- return days;
22
- });
3
+ export function colsCount(state) {
4
+ return derived(state.hiddenDays, $hiddenDays => 7 - $hiddenDays.length);
23
5
  }
@@ -1,18 +1,17 @@
1
1
  <script>
2
- import {getContext} from 'svelte';
2
+ import {getContext, onMount} from 'svelte';
3
3
  import {
4
4
  addDay, addDuration, ancestor, assign, cloneDate, cloneEvent, copyTime, createDuration, getElementWithPayload,
5
5
  getPayload, isFunction, listen, listView, max, min, noop, rect, runAll, subtractDay, subtractDuration,
6
- timelineView, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates
6
+ toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates
7
7
  } from '#lib';
8
8
  import {animate, limit, eventDraggable} from './lib';
9
9
 
10
- let {_iEvents, _iClass, _events, _view, _dayGrid, _bodyEl, datesAboveResources, dateClick, dragConstraint,
11
- dragScroll, editable, eventStartEditable, eventDragMinDistance, eventDragStart, eventDragStop, eventDrop,
10
+ let {_iEvents, _iClass, _events, _view, _mainEl, dateClick, dragConstraint, dragScroll, editable,
11
+ eventStartEditable, eventDragMinDistance, eventDragStart, eventDragStop, eventDrop,
12
12
  eventLongPressDelay, eventResizeStart, eventResizeStop, eventResize, longPressDelay, resizeConstraint,
13
13
  selectable, select: selectFn, selectBackgroundColor, selectConstraint, selectLongPressDelay, selectMinDistance,
14
- slotDuration, slotHeight, slotWidth, unselect: unselectFn, unselectAuto, unselectCancel, validRange,
15
- view} = getContext('state');
14
+ slotDuration, unselect: unselectFn, unselectAuto, unselectCancel, validRange, view} = getContext('state');
16
15
 
17
16
  const ACTION_DRAG = 1;
18
17
  const ACTION_RESIZE_END = 2;
@@ -28,7 +27,7 @@
28
27
  let resource, newResource;
29
28
  let fromX, fromY;
30
29
  let toX, toY;
31
- let bodyEl, bodyRect, clipEl, clipRect;
30
+ let gridEl, scrollable;
32
31
  let delta;
33
32
  let allDay;
34
33
  let iClass;
@@ -181,12 +180,8 @@
181
180
  let dayEl = getElementWithPayload(toX, toY);
182
181
  ({allDay, date, resource} = getPayload(dayEl)(toX, toY));
183
182
 
184
- if (timelineView($view)) {
185
- bodyEl = clipEl = $_bodyEl;
186
- } else {
187
- bodyEl = ancestor(dayEl, resource ? 4 : 3);
188
- clipEl = ancestor(dayEl, resource && (dragging() || $datesAboveResources) ? 2 : 1);
189
- }
183
+ scrollable = $_mainEl === ancestor(dayEl, 3); // test for "all-day" slot
184
+ gridEl = ancestor(dayEl, 1);
190
185
  calcViewport();
191
186
 
192
187
  if (jsEvent.pointerType !== 'mouse') {
@@ -286,31 +281,31 @@
286
281
  }
287
282
 
288
283
  if ($dragScroll) {
289
- let thresholdY = $slotHeight * 2;
290
- let thresholdX = $slotWidth;
284
+ let thresholdY = 24;
285
+ let thresholdX = 24;
291
286
  animate(() => {
292
- if (bodyEl) {
293
- if (toY < thresholdY) {
294
- window.scrollBy(0, max(-10, (toY - thresholdY) / 3));
287
+ if (viewport) {
288
+ if (scrollable) {
289
+ if (toY < viewport.top + thresholdY) {
290
+ $_mainEl.scrollTop += max(-8, (toY - viewport.top - thresholdY) / 3);
291
+ }
292
+ if (toY > viewport.bottom - thresholdY) {
293
+ $_mainEl.scrollTop += min(8, (toY - viewport.bottom + thresholdY) / 3);
294
+ }
295
+ if (toX < viewport.left + thresholdX) {
296
+ $_mainEl.scrollLeft += max(-8, (toX - viewport.left - thresholdX) / 3);
297
+ }
298
+ if (toX > viewport.right - thresholdX) {
299
+ $_mainEl.scrollLeft += min(8, (toX - viewport.right + thresholdX) / 3);
300
+ }
295
301
  }
296
- if (toY < bodyRect.top + thresholdY) {
297
- bodyEl.scrollTop += max(-10, (toY - bodyRect.top - thresholdY) / 3);
302
+ if (toY < thresholdY) {
303
+ window.scrollBy(0, max(-8, (toY - thresholdY) / 3));
298
304
  }
299
305
  if (toY > window.innerHeight - thresholdY) {
300
- window.scrollBy(0, min(10, (toY - window.innerHeight + thresholdY) / 3));
301
- }
302
- if (toY > bodyRect.bottom - thresholdY) {
303
- bodyEl.scrollTop += min(10, (toY - bodyRect.bottom + thresholdY) / 3);
306
+ window.scrollBy(0, min(8, (toY - window.innerHeight + thresholdY) / 3));
304
307
  }
305
308
 
306
- if (timelineView($view)) {
307
- if (toX < bodyRect.left + thresholdX) {
308
- bodyEl.scrollLeft += max(-10, (toX - bodyRect.left - thresholdX) / 3);
309
- }
310
- if (toX > bodyRect.right - thresholdX) {
311
- bodyEl.scrollLeft += min(10, (toX - bodyRect.right + thresholdX) / 3);
312
- }
313
- }
314
309
  }
315
310
  });
316
311
  }
@@ -392,8 +387,7 @@
392
387
 
393
388
  interacting = false;
394
389
  action = fromX = fromY = toX = toY = event = display = date = newDate = resource = newResource = delta =
395
- extraDuration = allDay = $_iClass = minResize = selectStep = margin = undefined;
396
- bodyEl = clipEl = bodyRect = clipRect = undefined;
390
+ extraDuration = allDay = $_iClass = minResize = selectStep = margin = gridEl = viewport = undefined;
397
391
 
398
392
  if (timer) {
399
393
  clearTimeout(timer);
@@ -407,8 +401,8 @@
407
401
  function findDayEl() {
408
402
  // Limit coordinates to viewport
409
403
  return getElementWithPayload(
410
- limit(toX, viewport[0], viewport[1]),
411
- limit(toY, viewport[2], viewport[3])
404
+ limit(toX, viewport.left, viewport.right),
405
+ limit(toY, viewport.top, viewport.bottom)
412
406
  );
413
407
  }
414
408
 
@@ -430,14 +424,14 @@
430
424
  }
431
425
 
432
426
  function calcViewport() {
433
- bodyRect = rect(bodyEl);
434
- clipRect = rect(clipEl);
435
- viewport = [
436
- max(0, clipRect.left + (timelineView($view) ? 1 : ($_dayGrid ? 0 : 8))), // left
437
- min(document.documentElement.clientWidth, clipRect.left + clipEl.clientWidth) - 2, // right
438
- max(0, bodyRect.top), // top
439
- min(document.documentElement.clientHeight, bodyRect.top + bodyEl.clientHeight) - 2 // bottom
440
- ];
427
+ let mainRect = rect($_mainEl);
428
+ let gridRect = rect(gridEl);
429
+ viewport = {
430
+ left: max(0, gridRect.left + $_mainEl.scrollLeft),
431
+ right: min(document.documentElement.clientWidth, mainRect.left + $_mainEl.clientWidth) - 2,
432
+ top: max(0, gridRect.top + (scrollable ? $_mainEl.scrollTop : 0)),
433
+ bottom: min(document.documentElement.clientHeight, scrollable ? mainRect.top + $_mainEl.clientHeight : gridRect.bottom) - 2
434
+ };
441
435
  }
442
436
 
443
437
  function createIEvent(jsEvent, callback) {
@@ -582,7 +576,6 @@
582
576
  let target = jsEvent.target;
583
577
  let stops = [];
584
578
  let stop = () => runAll(stops);
585
- stops.push(listen(window, 'touchmove', noop, {passive: false}))
586
579
  stops.push(listen(target, 'touchmove', createPreventDefaultHandler(() => interacting)));
587
580
  stops.push(listen(target, 'touchend', stop));
588
581
  stops.push(listen(target, 'touchcancel', stop));
@@ -596,6 +589,8 @@
596
589
  }
597
590
  };
598
591
  }
592
+
593
+ onMount(() => listen(window, 'touchmove', noop, {passive: false}));
599
594
  </script>
600
595
 
601
596
  <svelte:window
@@ -6,7 +6,7 @@
6
6
  import Pointer from './Pointer.svelte';
7
7
  import Resizer from './Resizer.svelte';
8
8
 
9
- let {theme, editable, eventStartEditable, pointer, _bodyEl,
9
+ let {theme, editable, eventStartEditable, pointer, _mainEl,
10
10
  _interaction, _iClasses} = getContext('state');
11
11
 
12
12
  $_interaction.resizer = Resizer;
@@ -31,12 +31,12 @@
31
31
  });
32
32
 
33
33
  $effect(() => {
34
- if ($_bodyEl) {
35
- return listen($_bodyEl, 'scroll', bodyScrollHandler);
34
+ if ($_mainEl) {
35
+ return listen($_mainEl, 'scroll', mainElScrollHandler);
36
36
  }
37
37
  });
38
38
 
39
- function bodyScrollHandler() {
39
+ function mainElScrollHandler() {
40
40
  for (let component of Object.values($_interaction)) {
41
41
  component?.handleScroll?.();
42
42
  }
@@ -18,14 +18,13 @@
18
18
  if (dayEl) {
19
19
  let {allDay, date, resource, disabled} = getPayload(dayEl)(x, y);
20
20
  if (!disabled) {
21
- let idx = allDay ? 2 : 1;
22
-
23
- if (!$_iEvents[idx]) {
24
- createPointerEvent(idx);
21
+ if (!$_iEvents[1]) {
22
+ createPointerEvent();
25
23
  }
26
- $_iEvents[idx].start = date;
27
- $_iEvents[idx].end = addDuration(cloneDate(date), $slotDuration);
28
- $_iEvents[idx].resourceIds = resource ? [resource.id] : [];
24
+ $_iEvents[1].allDay = allDay;
25
+ $_iEvents[1].start = date;
26
+ $_iEvents[1].end = addDuration(cloneDate(date), $slotDuration);
27
+ $_iEvents[1].resourceIds = resource ? [resource.id] : [];
29
28
 
30
29
  return;
31
30
  }
@@ -46,8 +45,8 @@
46
45
  }
47
46
  }
48
47
 
49
- function createPointerEvent(idx) {
50
- $_iEvents[idx] = {
48
+ function createPointerEvent() {
49
+ $_iEvents[1] = {
51
50
  id: '{pointer}',
52
51
  title: '',
53
52
  display: 'pointer',
@@ -62,9 +61,6 @@
62
61
  if ($_iEvents[1]) {
63
62
  $_iEvents[1] = null;
64
63
  }
65
- if ($_iEvents[2]) {
66
- $_iEvents[2] = null;
67
- }
68
64
  }
69
65
 
70
66
  function validEvent(jsEvent) {
@@ -20,8 +20,8 @@
20
20
  jsEvent,
21
21
  start,
22
22
  axis,
23
- forceDate?.(),
24
- forceMargin?.(),
23
+ forceDate,
24
+ forceMargin,
25
25
  chunk.zeroDuration
26
26
  );
27
27
  }
@@ -13,8 +13,4 @@ export function animate(fn) {
13
13
 
14
14
  export function limit(value, minLimit, maxLimit) {
15
15
  return max(minLimit, min(maxLimit, value));
16
- }
17
-
18
- export function draggable(event) {
19
-
20
- }
16
+ }