morphing-scroll 2.2.20 → 2.3.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.
package/README.md CHANGED
@@ -51,7 +51,10 @@ import Morph from "morphing-scroll";
51
51
  Start using the `MorphScroll` component by defining the required `size` prop. For better precision and control, it's recommended to begin by understanding the `objectsSize` and `progressTrigger` props, which are explained below.
52
52
 
53
53
  > **✦ Note:**
54
- > `MorphScroll` supports only **ESM** (`import`) build
54
+ > `MorphScroll` supports both **ESM** and **CommonJS** builds:
55
+ >
56
+ > - **Modern bundlers** (e.g. _Vite_, _Webpack 5_, _esbuild_) use the **ESM** (`import`) build
57
+ > - **Node.js** (and older environments) use the **CommonJS** (`require`) build
55
58
 
56
59
  <h2></h2>
57
60
 
@@ -70,7 +73,8 @@ Start using the `MorphScroll` component by defining the required `size` prop. Fo
70
73
  ##### **GENERAL SETTINGS**:
71
74
 
72
75
  <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
73
- <b>Type:</b> string<br />
76
+ <b>Type:</b><br />
77
+ string<br />
74
78
  <br />
75
79
  <b>Description:</b> <em><br />
76
80
  This parameter allows you to add additional classes to the component.</em><br />
@@ -88,7 +92,8 @@ This parameter allows you to add additional classes to the component.</em><br />
88
92
  <h2></h2>
89
93
 
90
94
  <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
91
- <b>Type:</b> React.ReactNode<br />
95
+ <b>Type:</b><br />
96
+ React.ReactNode<br />
92
97
  <br />
93
98
  <b>Description:</b> <em><br />
94
99
  This is where you can pass your list elements.<br />
@@ -108,9 +113,11 @@ Additionally, <code>MorphScroll</code> handles a passed <mark>null</mark> value
108
113
  ##### **SCROLL SETTINGS**:
109
114
 
110
115
  <details><summary><b><code>type</code></b>: <em>Type of progress element.</em></summary><br /><ul><div>
111
- <b>Type:</b> "scroll" | "slider" | "sliderMenu"<br />
116
+ <b>Type:</b><br />
117
+ "scroll" | "slider" | "sliderMenu"<br />
112
118
  <br />
113
- <b>Default:</b> "scroll"<br />
119
+ <b>Default:</b><br />
120
+ "scroll"<br />
114
121
  <br />
115
122
  <b>Description:</b> <em><br />
116
123
  This parameter defines how the provided <code>progressElement</code> behaves within <code>progressTrigger</code> and how you interact with it.<br />
@@ -136,9 +143,11 @@ This parameter defines how the provided <code>progressElement</code> behaves wit
136
143
  <h2></h2>
137
144
 
138
145
  <details><summary><b><code>direction</code></b>: <em>Scrolling direction.</em></summary><br /><ul><div>
139
- <b>Type:</b> "x" | "y" | "hybrid"<br />
146
+ <b>Type:</b><br />
147
+ "x" | "y" | "hybrid"<br />
140
148
  <br />
141
- <b>Default:</b> "y"<br />
149
+ <b>Default:</b><br />
150
+ "y"<br />
142
151
  <br />
143
152
  <b>Description:</b> <em><br />
144
153
  This parameter changes the scroll or slider type direction based on the provided value.<br />
@@ -159,13 +168,17 @@ You can set the value to horizontal, vertical or hybrid positions to customize t
159
168
  <h2></h2>
160
169
 
161
170
  <details><summary><b><code>scrollPosition</code></b>: <em>Scroll position and additional options.</em></summary><br /><ul><div>
162
- <b>Type:</b> {<br />
163
- value: number | "end" | (number | "end")[];<br />
164
- duration?: number;<br />
165
- updater?: boolean;<br />
171
+ <b>Type:</b><br />
172
+ {<br />
173
+ <ul>
174
+ value: number | "end" | (number | "end")[];<br />
175
+ duration?: number;<br />
176
+ updater?: boolean;<br />
177
+ </ul>
166
178
  }<br />
167
179
  <br />
168
- <b>Default:</b> { duration: 200; updater: false }<br />
180
+ <b>Default:</b><br />
181
+ { duration: 200; updater: false }<br />
169
182
  <br />
170
183
  <b>Description:</b> <em><br />
171
184
  This parameter allows you to set custom scroll values.<br />
@@ -201,7 +214,8 @@ This property is a helper for the <code>value</code> property. When setting the
201
214
  <h2></h2>
202
215
 
203
216
  <details><summary><b><code>onScrollValue</code></b>: <em>Callback for scroll value.</em></summary><br /><ul><div>
204
- <b>Type:</b> ( left: number, top: number ) => void<br />
217
+ <b>Type:</b><br />
218
+ ( left: number, top: number ) => void<br />
205
219
  <br />
206
220
  <b>Description:</b> <em><br />
207
221
  This parameter accepts a callback function that is triggered on every scroll event. The callback receives the current scroll top and left position as a number. The return value of the callback can be used to determine custom behavior based on the scroll value.</em><br />
@@ -223,7 +237,8 @@ This parameter accepts a callback function that is triggered on every scroll eve
223
237
  <h2></h2>
224
238
 
225
239
  <details><summary><b><code>isScrolling</code></b>: <em>Callback function for scroll status.</em></summary><br /><ul><div>
226
- <b>Type:</b> ( motion: boolean ) => void<br />
240
+ <b>Type:</b><br />
241
+ ( motion: boolean ) => void<br />
227
242
  <br />
228
243
  <b>Description:</b> <em><br />
229
244
  This parameter accepts a callback function that is triggered whenever the scroll status changes. The callback receives a boolean value, where <code>true</code> indicates that scrolling is in progress, and <code>false</code> indicates that scrolling has stopped. This can be useful for triggering additional actions, such as pausing animations or loading indicators based on the scroll state.</em><br />
@@ -248,7 +263,8 @@ This parameter accepts a callback function that is triggered whenever the scroll
248
263
  ##### **VISUAL SETTINGS**:
249
264
 
250
265
  <details><summary><b><code>size</code> REQUIRED</b>: <em>[width, height] dimension of <b>MorphScroll</b>.</em></summary><br /><ul><div>
251
- <b>Type:</b><br /> number | number[] | "auto"<br />
266
+ <b>Type:</b><br />
267
+ number | number[] | "auto"<br />
252
268
  <br />
253
269
  <b>Description:</b> <em><br />
254
270
  This parameter sets the width and height of the <code>MorphScroll</code>.<br />
@@ -276,7 +292,8 @@ This parameter sets the width and height of the <code>MorphScroll</code>.<br />
276
292
  number | "size" | "firstChild" | "none"<br />
277
293
  | (number | "size" | "firstChild" | "none")[]<br />
278
294
  <br />
279
- <b>Default:</b> If you don't provide any value, the default value will be taken from <code>size</code><br />
295
+ <b>Default:</b><br />
296
+ If you don't provide any value, the default value will be taken from <code>size</code><br />
280
297
  <br />
281
298
  <b>Description:</b> <em><br />
282
299
  This parameter defines the [width, height] of cells for each of your objects.<br />
@@ -317,7 +334,8 @@ This can be useful if you want to change the size of objects in your list dynami
317
334
  <h2></h2>
318
335
 
319
336
  <details><summary><b><code>crossCount</code></b>: <em>Number of cells in each direction.</em></summary><br /><ul><div>
320
- <b>Type:</b> number<br />
337
+ <b>Type:</b><br />
338
+ number<br />
321
339
  <br />
322
340
  <b>Description:</b> <em><br />
323
341
  This parameter defines the number of <b>columns</b> (<code>direction="y"</code>, <code>direction="hybrid"</code> + <code>elementsDirection="column"</code>) or <b>rows</b> (<code>direction="x"</code>, <code>direction="hybrid"</code> + <code>elementsDirection="row"</code>).<br />
@@ -343,7 +361,8 @@ This parameter defines the number of <b>columns</b> (<code>direction="y"</code>,
343
361
  <h2></h2>
344
362
 
345
363
  <details><summary><b><code>gap</code></b>: <em>Gap between cells.</em></summary><br /><ul><div>
346
- <b>Type:</b> number | number[]<br />
364
+ <b>Type:</b><br />
365
+ number | number[]<br />
347
366
  <br />
348
367
  <b>Description:</b> <em><br />
349
368
  This parameter allows you to set spacing in pixels between list items for rows and columns.<br />
@@ -366,7 +385,8 @@ It can be 1 number or an array of 2 numbers.</em><br />
366
385
  <h2></h2>
367
386
 
368
387
  <details><summary><b><code>wrapperMargin</code></b>: <em>Margin for the <b>.ms-objects-wrapper</b>.</em></summary><br /><ul><div>
369
- <b>Type:</b> number | number[]<br />
388
+ <b>Type:</b><br />
389
+ number | number[]<br />
370
390
  <br />
371
391
  <b>Description:</b> <em><br />
372
392
  This parameter defines the spacing between the list items and their wrapper, effectively increasing the width or height of the scrollable area.<br />
@@ -389,7 +409,9 @@ Can be 1 number or an array of 2 or 4 numbers in pixels.</em><br />
389
409
  <h2></h2>
390
410
 
391
411
  <details><summary><b><code>wrapperMinSize</code></b>: <em>Minimum height or width of the <b>.ms-objects-wrapper</b>.</em></summary><br /><ul><div>
392
- <b>Type:</b> number | "full" | (number | "full")[]<br /><br />
412
+ <b>Type:</b><br />
413
+ number | "full" | (number | "full")[]<br />
414
+ <br />
393
415
  <b>Description:</b> <em><br />
394
416
  This parameter defines the minimum height or width of the <b>.ms-objects-wrapper</b>, to which CSS properties like <code>min-height</code> or <code>min-width</code> will be applied.<br />
395
417
  <br />
@@ -436,7 +458,8 @@ Use 1 value to align one or both axes, or an array of 2 values to align both axe
436
458
  <h2></h2>
437
459
 
438
460
  <details><summary><b><code>elementsAlign</code></b>: <em>Aligns the objects inside <code>MorphScroll</code>.</em></summary><br /><ul><div>
439
- <b>Type:</b> "start" | "center" | "end"<br />
461
+ <b>Type:</b><br />
462
+ "start" | "center" | "end"<br />
440
463
  <br />
441
464
  <b>Example:</b>
442
465
 
@@ -453,9 +476,11 @@ Use 1 value to align one or both axes, or an array of 2 values to align both axe
453
476
  <h2></h2>
454
477
 
455
478
  <details><summary><b><code>elementsDirection</code></b>: <em>Direction of the provided elements.</em></summary><br /><ul><div>
456
- <b>Type:</b> "row" | "column"<br />
479
+ <b>Type:</b><br />
480
+ "row" | "column"<br />
457
481
  <br />
458
- <b>Default:</b> "row"<br />
482
+ <b>Default:</b><br />
483
+ "row"<br />
459
484
  <br />
460
485
  <b>Description:</b> <em><br />
461
486
  This parameter changes the order of the provided elements based on the provided value.</em><br />
@@ -475,19 +500,21 @@ This parameter changes the order of the provided elements based on the provided
475
500
  <h2></h2>
476
501
 
477
502
  <details><summary><b><code>edgeGradient</code></b>: <em>Gradient overlay at the edges of the scroll area.</em></summary><br /><ul><div>
478
- <b>Type:</b> boolean | { color?: string; size?: number }<br />
503
+ <b>Type:</b><br />
504
+ boolean | { color?: string; size?: number }<br />
479
505
  <br />
480
- <b>Default:</b> { size: 40 }<br />
506
+ <b>Default:</b><br />
507
+ { size: 40 }<br />
481
508
  <br />
482
509
  <b>Description:</b> <em><br />
483
510
  This parameter creates two edge elements responsible for darkening the edges of the scroll when it overflows.<br />
484
511
  <br />
485
- <code>color</code> :<br />
512
+ <code>color</code>:<br />
486
513
  The property accepts any valid color format.
487
514
  If you provide it, the library will generate a gradient transitioning from the custom color to transparent.
488
515
  If you provide just <mark>true</mark>, the edge elements will have no color, allowing for custom styling via CSS classes.<br />
489
516
  <br />
490
- <code>size</code> :<br />
517
+ <code>size</code>:<br />
491
518
  The property changes the height for horizontal and width for vertical <b>.ms-edge</b>.</em><br />
492
519
  <br />
493
520
  <b>Example:</b>
@@ -510,39 +537,52 @@ The property changes the height for horizontal and width for vertical <b>.ms-edg
510
537
  ##### **PROGRESSBAR**:
511
538
 
512
539
  <details><summary><b><code>progressTrigger</code></b>: <em>Triggers for the scroll progress.</em></summary><br /><ul><div>
513
- <b>Type:</b> {<br />
514
- wheel?: boolean;<br />
515
- content?: boolean;<br />
516
- progressElement?: boolean | React.ReactNode | React.ReactNode[];<br />
517
- arrows?: boolean | { size?: number; element?: React.ReactNode };<br />
540
+ <b>Type:</b><br />
541
+ {<br />
542
+ <ul>
543
+ wheel?: boolean | { changeDirection?: boolean; changeDirectionKey?: string };<br />
544
+ content?: boolean;<br />
545
+ progressElement?: boolean | React.ReactNode | React.ReactNode[];<br />
546
+ arrows?: boolean | { size?: number; element?: React.ReactNode };<br />
547
+ </ul>
518
548
  }<br />
519
549
  <br />
520
- <b>Default:</b> { wheel: true }<br />
550
+ <b>Default:</b><br />
551
+ { wheel: true }<br />
521
552
  <br />
522
553
  <b>Description:</b> <em><br />
523
554
  This is one of the most important properties, allowing you to define how users interact with the progress bar and customize its appearance.<br />
524
555
  <br />
525
- <code>wheel</code> :<br />
526
- This parameter determines whether the progress bar responds to mouse wheel scrolling.<br />
556
+ <code>wheel</code>:<br />
557
+ Determines whether the progress bar responds to mouse wheel scrolling.<br />
558
+ If you use <code>direction="hybrid"</code>, you can use:
559
+ <ul>
560
+ <li><code>changeDirection</code>: allows switching the scroll direction with the mouse wheel.</li>
561
+ <li><code>changeDirectionKey</code>: enables switching the scroll direction by pressing a specific key (default: <mark>"KeyX"</mark>).<br />
562
+ To disable this behavior, pass an empty string.<br />
563
+ <a href="https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values">more about keys</a></li>
564
+ </ul>
527
565
  <br />
528
- <code>content</code> :<br />
566
+ <code>content</code>:<br />
529
567
  This parameter enables interaction by clicking and dragging anywhere within the scrollable content to move it.<br />
530
568
  <br />
531
- <code>progressElement</code> :<br />
569
+ <code>progressElement</code>:<br />
532
570
  This parameter determines how the scroll progress is managed.<br />
533
571
  <br />
534
572
  <ul>
535
- <li>When using <code>type="scroll"</code>, you can provide a custom scroll element. If it's not ready yet, simply set <mark>true</mark> instead — this will fall back to the browser’s default scrollbar.</li>
536
- <li>When using <code>type="slider"</code>, a <b>.ms-slider</b> element is automatically generated. It contains multiple <b>ms-slider-element</b> elements that visually represent the scroll progress. One of them will always have the <code>active</code> class depending on the current position.</li>
573
+ <li>When using <code>type="scroll"</code>, you can provide a custom scroll element. If it's not ready yet, simply set <mark>true</mark> instead — this will fall back to the browser’s default scrollbar.</li><br />
574
+ <li>When using <code>type="slider"</code>, a <b>.ms-slider</b> element is automatically generated. It contains multiple <b>ms-slider-element</b> elements that visually represent the scroll progress. One of them will always have the <code>active</code> class depending on the current position.</li><br />
537
575
  <li>When using <code>type="sliderMenu"</code>, everything is the same as with <mark>"slider"</mark> but you can pass an array of custom buttons to <code>progressElement</code>. These buttons act as a navigation menu, allowing users to jump to specific sections.</li>
538
576
  </ul>
539
577
  <br />
540
- <code>arrows</code> :<br />
578
+ <code>arrows</code>:<br />
541
579
  This parameter allows you to add custom arrows to the progress bar. You can either specify a <code>size</code> for the arrows and provide a custom element.<br />
542
580
  <br />
543
581
  ✦ Note:<br />
544
- <code>progressTrigger</code> can only create or provide your elements, but you must make the design for them yourself.</em><br />
545
- <br />
582
+ <ul>
583
+ <li><code>progressTrigger</code> can only create or provide elements, but you must make the design for them yourself.</li>
584
+ <li>The Library scroll element automatically receives <code>:focus</code> when you start scrolling with the mouse wheel.</li>
585
+ </ul></em><br />
546
586
  <b>Example:</b>
547
587
 
548
588
  ```tsx
@@ -562,9 +602,11 @@ This parameter allows you to add custom arrows to the progress bar. You can eith
562
602
  <h2></h2>
563
603
 
564
604
  <details><summary><b><code>progressReverse</code></b>: <em>Reverse the progress bar position.</em></summary><br /><ul><div>
565
- <b>Type:</b> boolean | boolean[]<br />
605
+ <b>Type:</b><br />
606
+ boolean | boolean[]<br />
566
607
  <br />
567
- <b>Default:</b> false<br />
608
+ <b>Default:</b><br />
609
+ false<br />
568
610
  <br />
569
611
  <b>Description:</b> <em><br />
570
612
  This parameter changes the position of the progress bar based on the direction property.<br />
@@ -590,9 +632,11 @@ This parameter changes the position of the progress bar based on the direction p
590
632
  <h2></h2>
591
633
 
592
634
  <details><summary><b><code>scrollBarOnHover</code></b>: <em>Hover visibility of the <b>progress bar</b>.</em></summary><br /><ul><div>
593
- <b>Type:</b> boolean<br />
635
+ <b>Type:</b><br />
636
+ boolean<br />
594
637
  <br />
595
- <b>Default:</b> false<br />
638
+ <b>Default:</b><br />
639
+ false<br />
596
640
  <br />
597
641
  <b>Description:</b> <em><br />
598
642
  This parameter controls the visibility of the progress bar regardless of the <code>type</code> value.<br />
@@ -615,11 +659,14 @@ When you use it, the <b>"hover"</b> class is applied to the <b>.ms-bar</b> when
615
659
  ##### **OPTIMIZATIONS**:
616
660
 
617
661
  <details><summary><b><code>render</code></b>: <em>Rendering strategy for performance optimization.</em></summary><br /><ul><div>
618
- <b>Type:</b> {<br />
662
+ <b>Type:</b><br />
663
+ {<br />
664
+ <ul>
619
665
  type: "lazy" | "virtual";<br />
620
666
  rootMargin?: number | number[];<br />
621
667
  stopLoadOnScroll?: boolean;<br />
622
- }<br />
668
+ </ul>
669
+ }<br />
623
670
  <br />
624
671
  <b>Description:</b> <em><br />
625
672
  This parameter adds a gradual rendering of the content as it enters the viewport.<br />
@@ -655,28 +702,33 @@ This property controls whether to stop loading content when scrolling.<br />
655
702
  <h2></h2>
656
703
 
657
704
  <details><summary><b><code>emptyElements</code></b>: <em>Handling of empty scroll elements.</em></summary><br /><ul><div>
658
- <b>Type:</b> {<br />
659
- mode: "clear" | "fallback" | { fallback: React.ReactNode };<br />
660
- clickTrigger?: { selector: string; delay?: number };<br />
705
+ <b>Type:</b><br />
706
+ {<br />
707
+ <ul>
708
+ mode: "clear" | "fallback" | { fallback: React.ReactNode };<br />
709
+ clickTrigger?: { selector: string; delay?: number };<br />
710
+ </ul>
661
711
  }<br />
662
712
  <br />
663
713
  <b>Description:</b> <em><br />
664
714
  This option will allow you to delete or replace empty list items during the first rendering, or to start this process by clicking.<br />
665
715
  <br />
666
- <code>mode</code> :<br />
716
+ <code>mode</code>:<br />
667
717
  <ul>
668
718
  <li><mark>"clear"</mark> – automatically removes empty elements.</li>
669
719
  <li><mark>"fallback"</mark> – replaces empty elements with the value from the <code>fallback</code> props.</li>
670
720
  <li><mark>{ fallback: React.ReactNode }</mark> – if you need a different element than in <code>fallback</code> to replace empty elements, you can use this option.</li>
671
721
  </ul>
672
722
  <br />
673
- <code>clickTrigger</code> :<br />
723
+ <code>clickTrigger</code>:<br />
674
724
  In case if elements are removed via a click action, use this option. It accepts an object with a <code>selector</code> ( such as a delete button’s class ) and <code>delay</code> ( in <b>ms</b> ) to wait before removing the elements.<br />
675
725
  <br />
676
726
  ✦ Note:<br />
677
727
  <ul>
678
- <li>The cleanup will start on the initial render, when the number of passed elements changes, on scroll and on click if you use <code>clickTrigger</code>.</li>
679
- <li>If you are using <code>clickTrigger</code> but there are no changes, you may need to increase the <code>delay</code> value, since the cleanup function is triggered when your item has not yet been deleted.</li>
728
+ <li>The cleanup runs on the initial render, when the number of elements changes, on scroll, and on click if you use <code>clickTrigger</code>.</li>
729
+ <li>If you use <code>clickTrigger</code>:<br />
730
+ - consider increasing <code>delay</code>, since the cleanup may run before removal.<br />
731
+ - the wrapper <code>ms-object-box</code> also gets the <code>remove</code> class, which you can use e.g. for fade-out animations.</li>
680
732
  </ul></em>
681
733
  <br />
682
734
  <b>Example:</b>
@@ -700,9 +752,11 @@ In case if elements are removed via a click action, use this option. It accepts
700
752
  <h2></h2>
701
753
 
702
754
  <details><summary><b><code>suspending</code></b>: <em>Adds React Suspense.</em></summary><br /><ul><div>
703
- <b>Type:</b> boolean<br />
755
+ <b>Type:</b><br />
756
+ boolean<br />
704
757
  <br />
705
- <b>Default:</b> false<br />
758
+ <b>Default:</b><br />
759
+ false<br />
706
760
  <br />
707
761
  <b>Description:</b> <em><br />
708
762
  This parameter adds React Suspense to the MorphScroll component for asynchronous rendering.</em><br />
@@ -720,7 +774,8 @@ This parameter adds React Suspense to the MorphScroll component for asynchronous
720
774
  <h2></h2>
721
775
 
722
776
  <details><summary><b><code>fallback</code></b>: <em>Fallback element.</em></summary><br /><ul><div>
723
- <b>Type:</b> React.ReactNode<br />
777
+ <b>Type:</b><br />
778
+ React.ReactNode<br />
724
779
  <br />
725
780
  <b>Description:</b> <em><br />
726
781
  This parameter sets the fallback element to display during loading or placeholder.<br />
@@ -754,7 +809,8 @@ It will be used when:
754
809
  <ul><div>
755
810
 
756
811
  <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
757
- <b>Type:</b> string<br />
812
+ <b>Type:</b><br />
813
+ string<br />
758
814
  <br />
759
815
  <b>Description:</b> <em><br />
760
816
  This parameter allows you to add additional classes to the component.</em><br />
@@ -770,7 +826,8 @@ This parameter allows you to add additional classes to the component.</em><br />
770
826
  <h2></h2>
771
827
 
772
828
  <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
773
- <b>Type:</b> React.ReactNode<br />
829
+ <b>Type:</b><br />
830
+ React.ReactNode<br />
774
831
  <br />
775
832
  <b>Description:</b> <em><br />
776
833
  This parameter allows you to add custom content to the component.</em><br />
@@ -786,7 +843,8 @@ This parameter allows you to add custom content to the component.</em><br />
786
843
  <h2></h2>
787
844
 
788
845
  <details><summary><b><code>style</code></b>: <em>Applies inline styles to the container.</em></summary><br /><ul><div>
789
- <b>Type:</b> React.CSSProperties<br />
846
+ <b>Type:</b><br />
847
+ React.CSSProperties<br />
790
848
  <br />
791
849
  <b>Example:</b>
792
850
 
@@ -799,9 +857,11 @@ This parameter allows you to add custom content to the component.</em><br />
799
857
  <h2></h2>
800
858
 
801
859
  <details><summary><b><code>measure</code></b>: <em>Defines the measurement strategy.</em></summary><br /><ul><div>
802
- <b>Type:</b> "inner" | "outer" | "all"<br />
860
+ <b>Type:</b><br />
861
+ "inner" | "outer" | "all"<br />
803
862
  <br />
804
- <b>Default:</b> "inner"<br />
863
+ <b>Default:</b><br />
864
+ "inner"<br />
805
865
  <br />
806
866
  <b>Description:</b><br />
807
867
  <em>This prop determines what is being measured by automatically applying inline styles that affect width and height.<br />
@@ -826,7 +886,8 @@ Be cautious when overriding styles via the <code>style</code> prop, as it may in
826
886
  <h2></h2>
827
887
 
828
888
  <details><summary><b><code>onResize</code></b>: <em>Callback triggered on size changes.</em></summary><br /><ul><div>
829
- <b>Type:</b> (rect: Partial<DOMRectReadOnly>) => void<br />
889
+ <b>Type:</b><br />
890
+ (rect: Partial<DOMRectReadOnly>) => void<br />
830
891
  <br />
831
892
  <b>Description:</b><br />
832
893
  <em>A callback function that is triggered whenever the observed element's dimensions change.<br />
@@ -865,7 +926,8 @@ The function receives an object containing the updated size properties.</em><br
865
926
  <ul><div>
866
927
 
867
928
  <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
868
- <b>Type:</b> string<br />
929
+ <b>Type:</b><br />
930
+ string<br />
869
931
  <br />
870
932
  <b>Description:</b> <em><br />
871
933
  This parameter allows you to add additional classes to the component.</em><br />
@@ -881,7 +943,8 @@ This parameter allows you to add additional classes to the component.</em><br />
881
943
  <h2></h2>
882
944
 
883
945
  <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
884
- <b>Type:</b> React.ReactNode<br />
946
+ <b>Type:</b><br />
947
+ React.ReactNode<br />
885
948
  <br />
886
949
  <b>Example:</b>
887
950
 
@@ -894,7 +957,8 @@ This parameter allows you to add additional classes to the component.</em><br />
894
957
  <h2></h2>
895
958
 
896
959
  <details><summary><b><code>style</code></b>: <em>Applies inline styles to the container.</em></summary><br /><ul><div>
897
- <b>Type:</b> React.CSSProperties<br />
960
+ <b>Type:</b><br />
961
+ React.CSSProperties<br />
898
962
  <br />
899
963
  <b>Example:</b>
900
964
 
@@ -909,9 +973,11 @@ This parameter allows you to add additional classes to the component.</em><br />
909
973
  <h2></h2>
910
974
 
911
975
  <details><summary><b><code>root</code></b>: <em>Defines the observation area.</em></summary><br /><ul><div>
912
- <b>Type:</b> Element | null<br />
976
+ <b>Type:</b><br />
977
+ Element | null<br />
913
978
  <br />
914
- <b>Default:</b> null (window)<br />
979
+ <b>Default:</b><br />
980
+ null (window)<br />
915
981
  <br />
916
982
  <b>Description:</b> <em><br />
917
983
  Specifies the element that serves as the bounding box for the intersection observation.
@@ -930,7 +996,8 @@ If provided, it must be an ancestor of the observed element.</em><br />
930
996
  <h2></h2>
931
997
 
932
998
  <details><summary><b><code>rootMargin</code></b>: <em>Sets the margin around the root element.</em></summary><br /><ul><div>
933
- <b>Type:</b> number | number[]<br />
999
+ <b>Type:</b><br />
1000
+ number | number[]<br />
934
1001
  <br />
935
1002
  <b>Description:</b> <em><br />
936
1003
  Defines an offset around the root element, expanding or shrinking the observed area.<br />
@@ -949,9 +1016,11 @@ It can be a single number or an array of 2 <b>[ top-bottom, left-right ]</b> or
949
1016
  <h2></h2>
950
1017
 
951
1018
  <details><summary><b><code>threshold</code></b>: <em>Defines when the callback <code>onIntersection</code> and content visibility should be triggered.</em></summary><br /><ul><div>
952
- <b>Type:</b> number | number[]<br />
1019
+ <b>Type:</b><br />
1020
+ number | number[]<br />
953
1021
  <br />
954
- <b>Default:</b> 0<br />
1022
+ <b>Default:</b><br />
1023
+ 0<br />
955
1024
  <br />
956
1025
  <b>Description:</b> <em><br />
957
1026
  Specifies at what percentage of the observed element’s visibility the callback should be executed.<br />
@@ -973,9 +1042,11 @@ Specifies at what percentage of the observed element’s visibility the callback
973
1042
  <h2></h2>
974
1043
 
975
1044
  <details><summary><b><code>visibleContent</code></b>: <em>Makes all elements always visible.</em></summary><br /><ul><div>
976
- <b>Type:</b> boolean<br />
1045
+ <b>Type:</b><br />
1046
+ boolean<br />
977
1047
  <br />
978
- <b>Default:</b> false<br />
1048
+ <b>Default:</b><br />
1049
+ false<br />
979
1050
  <br />
980
1051
  <b>Description:</b> <em><br />
981
1052
  If set to <mark>true</mark>, the tracked elements will always be visible, regardless of their actual intersection status.<br />
@@ -992,7 +1063,8 @@ This is useful for testing purposes or when using the <code>onIntersection</code
992
1063
  <h2></h2>
993
1064
 
994
1065
  <details><summary><b><code>onIntersection</code></b>: <em>Callback function triggered when the element becomes visible.</em></summary><br /><ul><div>
995
- <b>Type:</b> (entry: IntersectionObserverEntry) => void<br />
1066
+ <b>Type:</b><br />
1067
+ (entry: IntersectionObserverEntry) => void<br />
996
1068
  <br />
997
1069
  <b>Description:</b> <em><br />
998
1070
  A callback function that is called when the observed element enters or leaves the viewport or the area defined by the <code>root</code> property. This can be used to load new list items for <code>MorphScroll</code>.<br />
package/cjs/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;r>t;t++)e.push(n[t%4]);n=e}return n},r=({className:r,children:n,style:o,root:l,threshold:s,rootMargin:i,visibleContent:c=!1,onIntersection:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=e.useMemo((()=>{if(!i)return"";const e=t(i);return`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px`}),[i]),h=e.useCallback((([e])=>{d(e.isIntersecting),a&&a({time:e.time,rootBounds:e.rootBounds,boundingClientRect:e.boundingClientRect,intersectionRect:e.intersectionRect,isIntersecting:e.isIntersecting,intersectionRatio:e.intersectionRatio,target:e.target})}),[a]);return e.useEffect((()=>{const e=new IntersectionObserver(h,{root:l,threshold:s,rootMargin:p});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[h,l,s,p]),e.createElement("div",{"intersection-tracker":"",className:r,ref:m,style:o},c||u?n:null)};r.displayName="IntersectionTracker";const n=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const s=e.useRef(null);e.useEffect((()=>{const e=s.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const i={width:"max-content",height:"max-content"},c={inner:Object.assign({},i),outer:Object.assign({},{width:"100%",height:"100%"}),all:Object.assign({minWidth:"100%",minHeight:"100%"},i)};return e.createElement("div",{"resize-tracker":"",className:t,ref:s,style:Object.assign(Object.assign({willChange:"width, height"},c[o]),n)},r)};function o(t,r){const n=e.useMemo((()=>function(e,t){let r=null,n=null;const o=(...o)=>{"requestFrame"===t?(null!==n&&cancelAnimationFrame(n),n=requestAnimationFrame((()=>{e(...o),n=null}))):(null!==r&&clearTimeout(r),r=setTimeout((()=>{e(...o),r=null}),t))};return o.cancel=()=>{null!==r&&(clearTimeout(r),r=null),null!==n&&(cancelAnimationFrame(n),n=null)},o}(t,r)),[r,t]);return e.useEffect((()=>()=>{n.cancel()}),[n]),n}n.displayName="ResizeTracker";let l=1;const s=({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:s,scrollBarEvent:i,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d,duration:m})=>{const p="sliderMenu"!==t?{onMouseDown:i,onTouchStart:i}:{},h=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",s="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"ms-slider-element",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{i(s*o,n,m,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,i,null==l?void 0:l.progressElement,m,d]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:o[0]+"px"},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),0!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign({height:c+"px",willChange:"transform, height",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"}),{transition:"height 0.05s ease-in-out"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),h))};s.displayName="ScrollBar";var i=e.memo(s);const c=({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:t.size+"px",top:0}:{width:"100%",height:t.size+"px",left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?" "+n:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})};c.displayName="Edge";var a=e.memo(c);const u=({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:r.size+"px"},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:l+"px"}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},s),onClick:()=>o(n)},r.element)};u.displayName="Arrow";var d=e.memo(u);function m(e,t){return e>t?Math.floor(e/t):1}function p(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const h=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)},f=e=>e?"start"===e?"flex-start":"center"===e?"center":"flex-end":void 0;function g(e,t,r=0,n=0){return o=>{var l,s,i,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(s=o.height)&&void 0!==s?s:0)-n};(null===(i=e.current)||void 0===i?void 0:i.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function y(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(t+"");else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function v(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,s={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const i=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:s.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:s.y,o=e.scrollElementRef;if("thumb"===e.clicked){const s=e.objectsWrapperRef,i=getComputedStyle(s),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?s.clientWidth+parseFloat(i.marginLeft)+parseFloat(i.marginRight):s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom),u=c-e.thumbSize,d=a-c;if(0>=u||0>=d)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),h=m-p;e.prevCoordsRef.current.leftover=h,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=s[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],i="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&i>c+l?e.smoothScroll(c+l,t,e.duration):0>o&&c>0&&e.smoothScroll(c-l,t,e.duration),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?i(t):"wrapp"===e.clicked?"slider"===e.type?c(t):i(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function b(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const x=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},E="wrap-id",j=new Map,w=(e,t,r)=>{O(e);const n=setTimeout((()=>{t(),j.delete(e)}),r);j.set(e,n)},O=e=>{const t=j.get(e);t&&(clearTimeout(t),j.delete(e))},S=({className:r,children:s,type:c="scroll",direction:u="y",scrollPosition:O,onScrollValue:S,isScrolling:R,size:M,objectsSize:k,crossCount:T,gap:z,wrapperMargin:A,wrapperMinSize:C,wrapperAlign:L,elementsAlign:F,elementsDirection:N="row",edgeGradient:I,progressTrigger:$={wheel:!0},progressReverse:X=!1,scrollBarOnHover:W=!1,render:B,emptyElements:H,suspending:Y=!1,fallback:P})=>{var q,D,K,V,_,U;const G=o((()=>{kt()}),40),J=o((()=>{Mt()}),34),Q=function(){const t=e.useRef(null);return null===t.current&&(t.current=""+l++),t.current}();if(!M)throw Error(`Prop "size" is not provided\nMorphScroll〈♦${Q}〉`);Object.keys($).length;const[Z,ee]=e.useState(0),te=()=>{ee((e=>"number"==typeof e&&1e3>e?e+1:0))},re=e.useRef(null),ne=e.useRef(null),oe=e.useRef(null),le=e.useRef(null),se=e.useRef([]),ie=e.useRef(null),ce=e.useRef("none"),ae=e.useRef({loaded:[],empty:[]}),ue=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),de=e.useRef(!1),me=e.useRef(0),pe=e.useRef(null),he=e.useRef(!1);function fe(){return e.useRef({width:0,height:0})}const ge=fe(),ye=fe(),ve=fe(),[be,xe,Ee,je,we,Oe,Se,Re,Me,ke]=function(...e){return e.map(y)}(null==O?void 0:O.value,B,M,k,H,C,L,z,$,ae.current.empty),Te=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==O?void 0:O.value)||"string"==typeof(null==O?void 0:O.value)?[O.value,O.value]:null!==(e=null==O?void 0:O.value)&&void 0!==e?e:[null],duration:null!==(t=null==O?void 0:O.duration)&&void 0!==t?t:200}}),[be,null==O?void 0:O.duration]),ze={color:null,size:40},Ae=e.useMemo((()=>"object"==typeof I?Object.assign(Object.assign({},ze),I):ze),[I]),Ce=e.useMemo((()=>Object.assign(Object.assign({},ze),"object"==typeof $.arrows?$.arrows:{})),[Me]),Le=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap(Le):[r]}return[t]}),[]),Fe=e.useMemo((()=>e.Children.toArray(s).flatMap(Le).map((t=>e.isValidElement(t)&&t.key?t.key+"":null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==H?void 0:H.mode)||!(null===(t=ae.current.empty)||void 0===t?void 0:t.includes(e))}))),[s,Le,we,ke]),[Ne,Ie,$e,Xe]=A?t(A):[0,0,0,0],We=Ne+$e,Be=Xe+Ie,[He,Ye]=e.useMemo((()=>{var e,t;return"number"==typeof z?[z,z]:Array.isArray(z)?[null!==(e=z[1])&&void 0!==e?e:0,null!==(t=z[0])&&void 0!==t?t:0]:[0,0]}),[z]),Pe=e.useMemo((()=>t((null==B?void 0:B.rootMargin)||0,"x"===u)),[xe,u]),[qe,De]=Pe?[Pe[2],Pe[0]]:[0,0],Ke=e.useMemo((()=>{const[e,t]=Array.isArray(M)?M:"number"==typeof M?[M,M]:[ge.current.width,ge.current.height];if(!$.arrows||!Ce.size)return[e,t,e,t];const r=2*Ce.size;let n=e,o=t;return"x"===u?n=e-r:"y"===u?o=t-r:"hybrid"===u&&(n=e-r,o=t-r),[n,o,e,t]}),[Ee,Me,u,Ce.size,ge.current.height,ge.current.width]),Ve="x"===u?Ke[0]:Ke[1],_e=e.useMemo((()=>k?Array.isArray(k)?k:t(k,!0,2):[null,null]),[je]),Ue=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(_e[0]&&"none"!==_e[0]&&"size"!==_e[0]?_e[0]:"y"===u&&"none"!==_e[0]||"size"===_e[0]?Ke[0]:0,ve.current.width),e(_e[1]&&"none"!==_e[1]&&"size"!==_e[1]?_e[1]:"x"===u&&"none"!==_e[1]||"size"===_e[1]?Ke[1]:0,ve.current.height)]}),[_e,u,ve.current.width,ve.current.height,Ke.join()]),Ge=e.useMemo((()=>{const e="x"===u,t="row"===N,r="column"===N,n=e?Ke[1]:Ke[0],o=e?Ue[1]+Ye:Ue[0]+He,l="hybrid"===u?o*(Fe.length+1)-o:n,s=Math.floor(l/o)||1,i=T&&s>=T?"hybrid"===u?Math.ceil(s/T):T:s,c=i>1&&i<Fe.length?Math.ceil(Fe.length/i):i>Fe.length?1:Fe.length,a=T&&T<Fe.length,d=e=>Number.isFinite(e)&&e>0?e:1;if("hybrid"===u){const e=a?t?T:i:t?Fe.length:1,n=a?r?T:i:r?Fe.length:1;return[d(e),d(n)]}return[d(i),d(c)]}),[N,Ye,He,Ue.join(),Fe.length,u,Ke.join(),T]),Je=e.useMemo((()=>{const e=Ge[0]?Ge[0]*Ye-Ye:0,t="x"===u?Ge[1]:Ge[0];return Ue[0]?(Ue[0]+Ye)*t-Ye:(null==B?void 0:B.type)?ve.current.width+e:ye.current.width}),[u,Ue[0],Ge.join(),Ye,ye.current.width,ve.current.width,null==B?void 0:B.type]),Qe=e.useMemo((()=>{const e=1>Ge[1]?1:Ge[0]*He-He;return Ue[1]?"x"===u?(Ue[1]+He)*Ge[0]-He:(Ue[1]+He)*Ge[1]-He:(null==B?void 0:B.type)?ve.current.height+e:ye.current.height}),[u,Ue[1],Ge.join(),He,ye.current.height,ve.current.height,null==B?void 0:B.type]),Ze=e.useMemo((()=>Qe+We),[Qe,We]),et=e.useMemo((()=>Je+Be),[Je,Be]),tt="x"===u?et:Ze,rt="x"===u?(null===(q=oe.current)||void 0===q?void 0:q.scrollLeft)||0:(null===(D=oe.current)||void 0===D?void 0:D.scrollTop)||0,nt=rt>1&&!0,ot=tt>Math.round(rt+Ve);let lt=!1,st=!1;"hybrid"===u&&(lt=((null===(K=oe.current)||void 0===K?void 0:K.scrollLeft)||0)>1&&!0,st=Math.round(((null===(V=oe.current)||void 0===V?void 0:V.scrollLeft)||0)+Ke[0])<et);const it=e.useMemo((()=>{if(!$.progressElement||!tt)return 0;const e=Math.round(Ve/tt*Ve);return!Number.isFinite(e)||0>e?0:e}),[Ve,tt,$.progressElement]),ct=e.useMemo((()=>{if(!$.progressElement)return 0;const e=Math.round(Ke[0]/et*Ke[0]);return!Number.isFinite(e)||0>e?0:e}),[Ke[0],et,$.progressElement]),at=e.useMemo((()=>Ve?tt-Ve:tt),[tt,Ve]),ut=e.useMemo((()=>Ke[0]?et-Ke[0]:et),[et,Ke[0]]),dt=e.useCallback((()=>{if(!(null==B?void 0:B.type)||1>=Ge[0])return[];const e=Array.from({length:Fe.length},((e,t)=>t)),t=Array.from({length:Ge[0]},(()=>[])),r="x"===u&&"column"===N||"x"!==u&&"row"===N;return e.forEach((e=>{const n=r?e%Ge[0]:Math.floor(e/Ge[1]);t[n]&&t[n].push(e)})),t}),[Fe.length,Ge.join(),null==B?void 0:B.type,N,u]),mt=e.useMemo((()=>{if(!(null==B?void 0:B.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if(F){const r=Array.from({length:Fe.length},((e,t)=>t)),n=Math.abs(Math.floor(Fe.length/Ge[0])*Ge[0]-Fe.length);e=n?r.slice(-n):[],"center"===F?t=(Ue[0]+Ye)*(Ge[0]-n)/2:"end"===F&&(t=(Ue[0]+Ye)*(Ge[0]-n))}return Fe.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n)return["x"===u?n:r,["hybrid","y"].includes(u)?n:r]}return[0,0]}(n,dt()),l=e.length>0&&e.includes(n)?t:0,s=function(e){const t="x"===u?l:0;return e>0?t+(Ue[1]+He)*e:t}(Ge[0]>1||["hybrid","x"].includes(u)?o[1]:n),i=Ue[1]?s+Ue[1]:s,c=function(e){const t="x"===u?0:l;return e>0?t+(Ue[0]+Ye)*e:t}(1===Ge[0]&&"x"===u?n:o[0]);return{elementTop:s,elementBottom:i,left:c,right:c+Ue[0]}}))}),[u,Ge[0],Ue.join(),He,Ye,null==B?void 0:B.type,N,F,dt,Fe.join()]),pt=e.useMemo((()=>(null==Ke?void 0:Ke.length)&&L?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,s={display:"flex"};return t[0]>r&&(s.justifyContent=f(o)),t[1]>n&&(s.alignItems=f(l)),s}(L,Ke,et,Ze):{}),[L,Ke.join(),Ze,et]),ht=e.useMemo((()=>[m(et,Ke[0]),m(Ze,Ke[1])]),[et,Ze,Ke.join()]),ft=e.useMemo((()=>"x"===u?ht[0]:ht[1]),[u,ht[0],ht[1]]),gt=o(g(ge,te),40),yt=o(g(ye,te,Be,We),40),vt=o(g(ve,te),40),bt=e.useCallback(((e,t,r,n)=>{const o=oe.current;return o?function(e,t,r,n,o){let l;if(!t&&!n)return null;const s=performance.now(),i=t.scrollTop,c=t.scrollLeft,a=u=>{const d=Math.min((u-s)/r,1);"y"===e?t.scrollTop=i+(n-i)*d:"x"===e&&(t.scrollLeft=c+(n-c)*d),1>d?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,o,r,e,n):null}),[]),xt=e.useCallback(((e,t,r)=>{if(ie.current){if(ie.current!==Fe[0])return void(ie.current=Fe[0])}else ie.current=Fe[0];const n=bt(t,e,Te.duration);n&&r.push(n)}),[Fe[0],Te.duration,bt]),Et=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:A?`${Ne}px ${Ie}px ${$e}px ${Xe}px`:"",height:_e[1]&&"none"!==_e[1]?Qe+"px":"fit-content",width:_e[0]&&"none"!==_e[0]?Je+"px":"fit-content"},$.content&&{cursor:"grab"}),z&&!(null==B?void 0:B.type)&&{gap:`${He}px ${Ye}px`}),C&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=l(e,t)+"px";return"x"===t?{minWidth:r}:{minHeight:r}}let s,i;return Array.isArray(e)?[s,i]=e:s=i=e,{minWidth:l(s,"x")+"px",minHeight:l(i,"y")+"px"}}(C,u,Ke,Be,We)),L&&{flexShrink:0});if(null==B?void 0:B.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=_e[1]?"wrap":void 0,r=1===Ge[0]?"y"===u?"column":"row":N;return Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:t,justifyContent:f(F)})}),[A,Se,Oe,[Ne,Ie,$e,Xe,Be,We,He,Ye].join(),Ke.join(),Re,_e[1],Qe,Je,$.content,Re,null==B?void 0:B.type,u,Ge[0],N,F]),jt=e.useCallback((e=>{if(!W)return;const t=()=>((e,t,r,n)=>{e&&e.querySelectorAll(".ms-bar").forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(ne.current,0,e,w);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ce.current)&&t():t()}),[W]),wt=e.useCallback(((e,t="mousedown",r)=>{const n=e||("scroll"===c?"thumb":"slider");if("wrapp"===e&&!$.content||["thumb","slider"].includes(n)&&!$.progressElement)return;h(c,re.current,se);let o=null;r&&(o=r.getAttribute("data-direction")),function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>v(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>b(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>{t.preventDefault(),v(Object.assign(Object.assign({},e),{mouseEvent:t}))}),{signal:r,passive:!1}),document.addEventListener("touchend",(r=>b(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:t,scrollElementRef:oe.current,objectsWrapperRef:le.current,scrollBar:r||null,clickedObject:ce,scrollContentRef:ne.current,scrollStateRef:ue.current,type:c,scrollBarOnHover:W,mouseOnEl:x,mouseOnRefHandle:jt,triggerUpdate:te,direction:u,smoothScroll:bt,sizeLocal:[Ke[0],Ke[1]],clicked:n,numForSliderRef:me,isScrollingRef:de,prevCoordsRef:pe,thumbSize:"x"===o?ct:it,axisFromAtr:o,duration:Te.duration})}),[u,c,$.content,$.progressElement,Ke.join(),it,ct,Te.duration,bt,jt,W]),Ot=e.useCallback((e=>{wt(null,e.type,e.target)}),[wt]),St=e.useCallback((()=>{wt("wrapp")}),[wt]),Rt=e.useCallback((e=>{oe.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o,duration:l})=>{const s=r[0],i=r[1],c=t.scrollTop,a=t.scrollLeft,u=["top","bottom"].includes(e)?i:s,d=(e,t)=>o(p(e,0,u),t,l);"top"===e&&c>0?d(c-n[1],"y"):"left"===e&&a>0&&d(a-n[0],"x"),"bottom"===e&&c+n[1]!==i?d(c+n[1],"y"):"right"===e&&a+n[0]!==s&&d(a+n[0],"x")})({arrowType:e,scrollElement:oe.current,wrapSize:[et,Ze],scrollSize:Ke,smoothScroll:bt,duration:Te.duration})}),[Ke.join(),et,Ze,Te.duration,bt]),Mt=e.useCallback((()=>{h(c,re.current,se);const e=oe.current;ne.current&&e&&0!==se.current.length&&((e,t,r,n)=>{!function(){var o,l,s,i;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".ms-slider-element"))&&void 0!==l?l:[],a=null!==(i=null===(s=t[1])||void 0===s?void 0:s.querySelectorAll(".ms-slider-element"))&&void 0!==i?i:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1];o>=l*r&&l*(r+1)>o?e.classList.add("active"):e.classList.remove("active")}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,se.current,Ke,u)}),[Ke.join(),u,oe,ne,c]),kt=e.useCallback((()=>{re.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(E)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(E);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),s=new Set(t.current.loaded);o.forEach((e=>s.add(e)));let i=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),i=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(s):o.map((e=>e)),empty:i},r()})(re.current,ae,te,null==B?void 0:B.type)}),[xe]),Tt=e.useCallback((e=>{(null==H?void 0:H.clickTrigger)&&((e,t,r,n)=>{const o=e.target;if(!o.closest(r.selector))return;const l=o.closest(`[${E}]`);l&&l.classList.add("remove"),t("emptyKeys-anim",(()=>{l&&l.classList.remove("remove"),n()}),r.delay||0)})(e,w,H.clickTrigger,kt)}),[we,kt]),zt=e.useCallback((()=>{const e=oe.current;e&&(null==S||S(e.scrollLeft,e.scrollTop),de.current=!0,null==R||R(!0),w("handleScroll-anim",(()=>{de.current=!1,null==R||R(!1),(null==B?void 0:B.type)?te():G()}),200),"slider"===c&&J(),(null==B?void 0:B.type)||G(),te())}),[S,R,c,null==B?void 0:B.type,J,kt]),At=p(rt/at*(Ve-it),0,Ve-it),Ct=p(((null===(_=oe.current)||void 0===_?void 0:_.scrollLeft)||0)/ut*(Ke[0]-Ke[0]/et*Ke[0]),0,Ke[0]-ct),Lt=e.useCallback((e=>{const t="object"==typeof $.wheel&&$.wheel.changeDirectionKey?$.wheel.changeDirectionKey:"KeyX";e.code!==t||"hybrid"!==u||he.current||(e.stopPropagation(),he.current=!0,te())}),[u,JSON.stringify($.wheel)]),Ft=e.useCallback((e=>{he.current&&(e.stopPropagation(),he.current=!1,te())}),[]);e.useEffect((()=>{(H||(null==B?void 0:B.type))&&(H||null===ae.current.empty||(ae.current.empty=null),G())}),[we,null==B?void 0:B.type,de.current,Fe.join(),kt]),e.useEffect((()=>{const e=ue.current.animationFrameId;return((null==B?void 0:B.type)||R)&&R&&(R(!1),te()),Mt(),()=>{e&&cancelAnimationFrame(e),(()=>{for(const e of j.values())clearTimeout(e);j.clear()})()}}),[]),e.useEffect((()=>{const e=oe.current;if(!e)return;const t=e=>e.preventDefault(),r="hybrid"===u&&"object"==typeof $.wheel&&$.wheel.changeDirection?"x":u,n="hybrid"===u&&Qe+We<=Ke[1]||he.current?["hybrid","y"].includes(r)?"x":"y":r,o=$.wheel?e=>{t(e),function(e,t,r){const n=e.target.closest(".ms-element");n.matches(":focus")||n.focus(),t.animating||(t.targetScrollX=n.scrollLeft,t.targetScrollY=n.scrollTop),"x"===r?t.targetScrollX=p(t.targetScrollX+e.deltaY,0,n.scrollWidth-n.clientWidth+2):t.targetScrollY=p(t.targetScrollY+e.deltaY,0,n.scrollHeight-n.clientHeight+2),t.animating||(t.animating=!0,t.animationFrameId=requestAnimationFrame((function e(){let o=0;"x"===r?(n.scrollLeft+=.4*(t.targetScrollX-n.scrollLeft),o=Math.abs(n.scrollLeft-t.targetScrollX)):(n.scrollTop+=.4*(t.targetScrollY-n.scrollTop),o=Math.abs(n.scrollTop-t.targetScrollY)),o>2.5?t.animationFrameId=requestAnimationFrame(e):(t.animating=!1,null!==t.animationFrameId&&(cancelAnimationFrame(t.animationFrameId),t.animationFrameId=null))})))}(e,ue.current,n)}:t;return e.addEventListener("wheel",o,{passive:!1}),()=>{e.removeEventListener("wheel",o)}}),[u,JSON.stringify($.wheel),Qe,Ke[1],We,he.current]),e.useEffect((()=>{if(!Te.value)return;const e=[];return("hybrid"===u?["x","y"]:[u]).forEach((t=>{const r="x"===t?0:1;"end"===Te.value[r]&&xt(t,"x"===t?ut:at,e)})),()=>{e.forEach((e=>e()))}}),[u,Te.value.join(),be,at,ut,et,Ze]),e.useEffect((()=>{if(!Te.value)return;const e=[];return("hybrid"===u?["x","y"]:[u]).forEach((t=>{const r="x"===t?0:1;"number"==typeof Te.value[r]&&xt(t,Te.value[r],e)})),()=>{e.forEach((e=>e()))}}),[be,null==O?void 0:O.updater,u,xt,Te.value.join()]);const Nt=e.useCallback(((t,r,n,o)=>{var l;const s=Object.assign({width:Ue[0]?Ue[0]+"px":void 0,height:Ue[1]?Ue[1]+"px":void 0},(null==B?void 0:B.type)&&Object.assign({position:"absolute",top:r+"px",left:n+"px"},!Ue[0]&&1===Ge[0]&&{transform:"translateX(-50%)"})),i=Y?e.createElement(e.Suspense,{fallback:P},o):o,c=(null===(l=null==H?void 0:H.clickTrigger)||void 0===l?void 0:l.selector)&&Tt;return e.createElement("div",Object.assign({key:t},B||H?{[E]:""+t}:{},{className:"ms-object-box",style:s,onClick:c}),i)}),[Y,!!P,Ue.join(),xe,we,Ge[0],Tt]),It=e.createElement("div",{className:"ms-objects-wrapper",ref:le,onMouseDown:St,style:Et},Fe.map(((t,r)=>{var o,l,i;const c=e.Children.toArray(s).find((r=>e.isValidElement(r)&&r.key===t)),a=(null==B?void 0:B.stopLoadOnScroll)&&de.current&&!ae.current.loaded.includes(""+t)?P:(null===(o=ae.current.empty)||void 0===o?void 0:o.includes(t))?"object"==typeof(null==H?void 0:H.mode)?H.mode.fallback:P:c,d="number"==typeof _e[0]&&"number"==typeof _e[1]||"firstChild"!==_e[0]&&"firstChild"!==_e[1]||0!==r?a:e.createElement(n,{onResize:vt},a);if(!(null==B?void 0:B.type))return Nt(t,0,0,d);{const{elementTop:e,elementBottom:n,left:o,right:s}=mt[r],c="x"===u?qe:De,a=Ve+c>("x"===u?o:e)-rt&&("x"===u?s:n)-rt>0-c,m="hybrid"!==u||Ke[0]+qe>o-((null===(l=oe.current)||void 0===l?void 0:l.scrollLeft)||0)&&s-((null===(i=oe.current)||void 0===i?void 0:i.scrollLeft)||0)>0-qe;if(a&&m)return Nt(t,e,o,d)}}))),$t=[{positionType:"x"===u?"left":"top",visibility:nt},{positionType:"x"===u?"right":"bottom",visibility:ot},..."hybrid"===u?[{positionType:"left",visibility:lt},{positionType:"right",visibility:st}]:[]],Xt=e.createElement("div",{"morph-scroll":`〈♦${Q}〉`,className:r,ref:re,style:{width:Ke[2]+"px",height:Ke[3]+"px"}},e.createElement("div",{className:"ms-content",ref:ne,onMouseEnter:jt,onMouseLeave:jt,onTouchStart:jt,onTouchEnd:jt,style:Object.assign({position:"relative",width:Ke[0]+"px",height:Ke[1]+"px"},$.arrows&&Ce.size&&("x"===u?{left:Ce.size+"px"}:"y"===u?{top:Ce.size+"px"}:{top:Ce.size+"px",left:Ce.size+"px"}))},e.createElement("div",{className:"ms-element",ref:oe,onScroll:zt,onKeyDown:Lt,onKeyUp:Ft,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%",outline:"none"},pt),{overflow:null!==(U={x:et>Ke[0]?"scroll hidden":"hidden",y:Ze>Ke[1]?"hidden scroll":"hidden",hybrid:`${et>Ke[0]?"scroll":"hidden"} ${Ze>Ke[1]?"scroll":"hidden"}`,hide:"hidden"}[$.wheel||$.content?u:"hide"])&&void 0!==U?U:"hidden"}),"scroll"!==c||"boolean"!=typeof $.progressElement||!1===$.progressElement?{scrollbarWidth:"none"}:{})},Ue[0]&&Ue[1]?It:e.createElement(n,{onResize:yt,style:Object.assign({},pt)},It)),I&&$t.map((({positionType:t,visibility:r})=>e.createElement(a,{key:"edge-"+t,edgeGradient:Ae,visibility:r,edgeType:t}))),$.progressElement&&!0!==$.progressElement&&[{shouldRender:tt>it,direction:u,thumbSize:it,thumbSpace:At,objLengthPerSize:ft,progressReverseIndex:0},{shouldRender:"hybrid"===u&&et>ct,direction:"x",thumbSize:ct,thumbSpace:Ct,objLengthPerSize:ht[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((t=>e.createElement(i,{key:t.direction,type:c,direction:t.direction,progressReverse:"boolean"==typeof X?X:X[t.progressReverseIndex],size:Ke,progressTrigger:$,scrollBarOnHover:W,scrollBarEvent:"sliderMenu"===c?bt:Ot,thumbSize:t.thumbSize,thumbSpace:t.thumbSpace,objLengthPerSize:t.objLengthPerSize,sliderCheckLocal:Mt,duration:Te.duration})))),$.arrows&&$t.map((({positionType:t,visibility:r})=>e.createElement(d,{key:"arrow-"+t,activity:r,arrows:Ce,arrowType:t,handleArrow:Rt,size:"hybrid"===u?Ke[0]+2*Ce.size:Ke[0]}))));return"auto"===M?e.createElement(n,{measure:"outer",onResize:gt},Xt):Xt};S.displayName="MorphScroll";const R={MorphScroll:S,ResizeTracker:n,IntersectionTracker:r};exports.IntersectionTracker=r,exports.MorphScroll=S,exports.ResizeTracker=n,exports.default=R;
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ import e,{useMemo as t,useEffect as r,useRef as n}from"react";const o=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;r>t;t++)e.push(n[t%4]);n=e}return n},l=({className:t,children:r,style:n,root:l,threshold:i,rootMargin:s,visibleContent:c=!1,onIntersection:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=e.useMemo((()=>{if(!s)return"";const e=o(s);return`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px`}),[s]),h=e.useCallback((([e])=>{d(e.isIntersecting),a&&a({time:e.time,rootBounds:e.rootBounds,boundingClientRect:e.boundingClientRect,intersectionRect:e.intersectionRect,isIntersecting:e.isIntersecting,intersectionRatio:e.intersectionRatio,target:e.target})}),[a]);return e.useEffect((()=>{const e=new IntersectionObserver(h,{root:l,threshold:i,rootMargin:p});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[h,l,i,p]),e.createElement("div",{"intersection-tracker":"",className:t,ref:m,style:n},c||u?r:null)};l.displayName="IntersectionTracker";const i=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const i=e.useRef(null);e.useEffect((()=>{const e=i.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const s={width:"max-content",height:"max-content"},c={inner:Object.assign({},s),outer:Object.assign({},{width:"100%",height:"100%"}),all:Object.assign({minWidth:"100%",minHeight:"100%"},s)};return e.createElement("div",{"resize-tracker":"",className:t,ref:i,style:Object.assign(Object.assign({willChange:"width, height"},c[o]),n)},r)};function s(e,n){const o=t((()=>function(e,t){let r=null,n=null;const o=(...o)=>{"requestFrame"===t?(null!==n&&cancelAnimationFrame(n),n=requestAnimationFrame((()=>{e(...o),n=null}))):(null!==r&&clearTimeout(r),r=setTimeout((()=>{e(...o),r=null}),t))};return o.cancel=()=>{null!==r&&(clearTimeout(r),r=null),null!==n&&(cancelAnimationFrame(n),n=null)},o}(e,n)),[n,e]);return r((()=>()=>{o.cancel()}),[o]),o}i.displayName="ResizeTracker";let c=1;const a=({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:i,scrollBarEvent:s,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d,duration:m})=>{const p="sliderMenu"!==t?{onMouseDown:s,onTouchStart:s}:{},h=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",i="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"ms-slider-element",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{s(i*o,n,m,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,s,null==l?void 0:l.progressElement,m,d]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:o[0]+"px"},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),0!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),i&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign({height:c+"px",willChange:"transform, height",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"}),{transition:"height 0.05s ease-in-out"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),i&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),h))};a.displayName="ScrollBar";var u=e.memo(a);const d=({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:t.size+"px",top:0}:{width:"100%",height:t.size+"px",left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?" "+n:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})};d.displayName="Edge";var m=e.memo(d);const p=({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const i=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:r.size+"px"},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:l+"px"}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},i),onClick:()=>o(n)},r.element)};p.displayName="Arrow";var h=e.memo(p);function f(e,t){return e>t?Math.floor(e/t):1}function g(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const y=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)},v=e=>e?"start"===e?"flex-start":"center"===e?"center":"flex-end":void 0;function b(e,t,r=0,n=0){return o=>{var l,i,s,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(i=o.height)&&void 0!==i?i:0)-n};(null===(s=e.current)||void 0===s?void 0:s.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function x(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(t+"");else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function E(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,i={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const s=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:i.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:i.y,o=e.scrollElementRef;if("thumb"===e.clicked){const i=e.objectsWrapperRef,s=getComputedStyle(i),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?i.clientWidth+parseFloat(s.marginLeft)+parseFloat(s.marginRight):i.clientHeight+parseFloat(s.marginTop)+parseFloat(s.marginBottom),u=c-e.thumbSize,d=a-c;if(0>=u||0>=d)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),h=m-p;e.prevCoordsRef.current.leftover=h,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=i[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],s="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&s>c+l?e.smoothScroll(c+l,t,e.duration):0>o&&c>0&&e.smoothScroll(c-l,t,e.duration),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?s(t):"wrapp"===e.clicked?"slider"===e.type?c(t):s(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function j(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const w=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},O="wrap-id",S=new Map,R=(e,t,r)=>{M(e);const n=setTimeout((()=>{t(),S.delete(e)}),r);S.set(e,n)},M=e=>{const t=S.get(e);t&&(clearTimeout(t),S.delete(e))},k=({className:t,children:r,type:l="scroll",direction:a="y",scrollPosition:d,onScrollValue:p,isScrolling:M,size:k,objectsSize:T,crossCount:z,gap:A,wrapperMargin:C,wrapperMinSize:L,wrapperAlign:F,elementsAlign:N,elementsDirection:I="row",edgeGradient:$,progressTrigger:X={wheel:!0},progressReverse:W=!1,scrollBarOnHover:B=!1,render:H,emptyElements:Y,suspending:P=!1,fallback:D})=>{var q,K,V,U,G,_;const J=s((()=>{Tt()}),40),Q=s((()=>{kt()}),34),Z=function(){const e=n(null);return null===e.current&&(e.current=""+c++),e.current}();if(!k)throw Error(`Prop "size" is not provided\nMorphScroll〈♦${Z}〉`);Object.keys(X).length;const[ee,te]=e.useState(0),re=()=>{te((e=>"number"==typeof e&&1e3>e?e+1:0))},ne=e.useRef(null),oe=e.useRef(null),le=e.useRef(null),ie=e.useRef(null),se=e.useRef([]),ce=e.useRef(null),ae=e.useRef("none"),ue=e.useRef({loaded:[],empty:[]}),de=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),me=e.useRef(!1),pe=e.useRef(0),he=e.useRef(null),fe=e.useRef(!1);function ge(){return e.useRef({width:0,height:0})}const ye=ge(),ve=ge(),be=ge(),[xe,Ee,je,we,Oe,Se,Re,Me,ke,Te]=function(...e){return e.map(x)}(null==d?void 0:d.value,H,k,T,Y,L,F,A,X,ue.current.empty),ze=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==d?void 0:d.value)||"string"==typeof(null==d?void 0:d.value)?[d.value,d.value]:null!==(e=null==d?void 0:d.value)&&void 0!==e?e:[null],duration:null!==(t=null==d?void 0:d.duration)&&void 0!==t?t:200}}),[xe,null==d?void 0:d.duration]),Ae={color:null,size:40},Ce=e.useMemo((()=>"object"==typeof $?Object.assign(Object.assign({},Ae),$):Ae),[$]),Le=e.useMemo((()=>Object.assign(Object.assign({},Ae),"object"==typeof X.arrows?X.arrows:{})),[ke]),Fe=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap(Fe):[r]}return[t]}),[]),Ne=e.useMemo((()=>e.Children.toArray(r).flatMap(Fe).map((t=>e.isValidElement(t)&&t.key?t.key+"":null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==Y?void 0:Y.mode)||!(null===(t=ue.current.empty)||void 0===t?void 0:t.includes(e))}))),[r,Fe,Oe,Te]),[Ie,$e,Xe,We]=C?o(C):[0,0,0,0],Be=Ie+Xe,He=We+$e,[Ye,Pe]=e.useMemo((()=>{var e,t;return"number"==typeof A?[A,A]:Array.isArray(A)?[null!==(e=A[1])&&void 0!==e?e:0,null!==(t=A[0])&&void 0!==t?t:0]:[0,0]}),[A]),De=e.useMemo((()=>o((null==H?void 0:H.rootMargin)||0,"x"===a)),[Ee,a]),[qe,Ke]=De?[De[2],De[0]]:[0,0],Ve=e.useMemo((()=>{const[e,t]=Array.isArray(k)?k:"number"==typeof k?[k,k]:[ye.current.width,ye.current.height];if(!X.arrows||!Le.size)return[e,t,e,t];const r=2*Le.size;let n=e,o=t;return"x"===a?n=e-r:"y"===a?o=t-r:"hybrid"===a&&(n=e-r,o=t-r),[n,o,e,t]}),[je,ke,a,Le.size,ye.current.height,ye.current.width]),Ue="x"===a?Ve[0]:Ve[1],Ge=e.useMemo((()=>T?Array.isArray(T)?T:o(T,!0,2):[null,null]),[we]),_e=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(Ge[0]&&"none"!==Ge[0]&&"size"!==Ge[0]?Ge[0]:"y"===a&&"none"!==Ge[0]||"size"===Ge[0]?Ve[0]:0,be.current.width),e(Ge[1]&&"none"!==Ge[1]&&"size"!==Ge[1]?Ge[1]:"x"===a&&"none"!==Ge[1]||"size"===Ge[1]?Ve[1]:0,be.current.height)]}),[Ge,a,be.current.width,be.current.height,Ve.join()]),Je=e.useMemo((()=>{const e="x"===a,t="row"===I,r="column"===I,n=e?Ve[1]:Ve[0],o=e?_e[1]+Pe:_e[0]+Ye,l="hybrid"===a?o*(Ne.length+1)-o:n,i=Math.floor(l/o)||1,s=z&&i>=z?"hybrid"===a?Math.ceil(i/z):z:i,c=s>1&&s<Ne.length?Math.ceil(Ne.length/s):s>Ne.length?1:Ne.length,u=z&&z<Ne.length,d=e=>Number.isFinite(e)&&e>0?e:1;if("hybrid"===a){const e=u?t?z:s:t?Ne.length:1,n=u?r?z:s:r?Ne.length:1;return[d(e),d(n)]}return[d(s),d(c)]}),[I,Pe,Ye,_e.join(),Ne.length,a,Ve.join(),z]),Qe=e.useMemo((()=>{const e=Je[0]?Je[0]*Pe-Pe:0,t="x"===a?Je[1]:Je[0];return _e[0]?(_e[0]+Pe)*t-Pe:(null==H?void 0:H.type)?be.current.width+e:ve.current.width}),[a,_e[0],Je.join(),Pe,ve.current.width,be.current.width,null==H?void 0:H.type]),Ze=e.useMemo((()=>{const e=1>Je[1]?1:Je[0]*Ye-Ye;return _e[1]?"x"===a?(_e[1]+Ye)*Je[0]-Ye:(_e[1]+Ye)*Je[1]-Ye:(null==H?void 0:H.type)?be.current.height+e:ve.current.height}),[a,_e[1],Je.join(),Ye,ve.current.height,be.current.height,null==H?void 0:H.type]),et=e.useMemo((()=>Ze+Be),[Ze,Be]),tt=e.useMemo((()=>Qe+He),[Qe,He]),rt="x"===a?tt:et,nt="x"===a?(null===(q=le.current)||void 0===q?void 0:q.scrollLeft)||0:(null===(K=le.current)||void 0===K?void 0:K.scrollTop)||0,ot=nt>1&&!0,lt=rt>Math.round(nt+Ue);let it=!1,st=!1;"hybrid"===a&&(it=((null===(V=le.current)||void 0===V?void 0:V.scrollLeft)||0)>1&&!0,st=Math.round(((null===(U=le.current)||void 0===U?void 0:U.scrollLeft)||0)+Ve[0])<tt);const ct=e.useMemo((()=>{if(!X.progressElement||!rt)return 0;const e=Math.round(Ue/rt*Ue);return!Number.isFinite(e)||0>e?0:e}),[Ue,rt,X.progressElement]),at=e.useMemo((()=>{if(!X.progressElement)return 0;const e=Math.round(Ve[0]/tt*Ve[0]);return!Number.isFinite(e)||0>e?0:e}),[Ve[0],tt,X.progressElement]),ut=e.useMemo((()=>Ue?rt-Ue:rt),[rt,Ue]),dt=e.useMemo((()=>Ve[0]?tt-Ve[0]:tt),[tt,Ve[0]]),mt=e.useCallback((()=>{if(!(null==H?void 0:H.type)||1>=Je[0])return[];const e=Array.from({length:Ne.length},((e,t)=>t)),t=Array.from({length:Je[0]},(()=>[])),r="x"===a&&"column"===I||"x"!==a&&"row"===I;return e.forEach((e=>{const n=r?e%Je[0]:Math.floor(e/Je[1]);t[n]&&t[n].push(e)})),t}),[Ne.length,Je.join(),null==H?void 0:H.type,I,a]),pt=e.useMemo((()=>{if(!(null==H?void 0:H.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if(N){const r=Array.from({length:Ne.length},((e,t)=>t)),n=Math.abs(Math.floor(Ne.length/Je[0])*Je[0]-Ne.length);e=n?r.slice(-n):[],"center"===N?t=(_e[0]+Pe)*(Je[0]-n)/2:"end"===N&&(t=(_e[0]+Pe)*(Je[0]-n))}return Ne.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n)return["x"===a?n:r,["hybrid","y"].includes(a)?n:r]}return[0,0]}(n,mt()),l=e.length>0&&e.includes(n)?t:0,i=function(e){const t="x"===a?l:0;return e>0?t+(_e[1]+Ye)*e:t}(Je[0]>1||["hybrid","x"].includes(a)?o[1]:n),s=_e[1]?i+_e[1]:i,c=function(e){const t="x"===a?0:l;return e>0?t+(_e[0]+Pe)*e:t}(1===Je[0]&&"x"===a?n:o[0]);return{elementTop:i,elementBottom:s,left:c,right:c+_e[0]}}))}),[a,Je[0],_e.join(),Ye,Pe,null==H?void 0:H.type,I,N,mt,Ne.join()]),ht=e.useMemo((()=>(null==Ve?void 0:Ve.length)&&F?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,i={display:"flex"};return t[0]>r&&(i.justifyContent=v(o)),t[1]>n&&(i.alignItems=v(l)),i}(F,Ve,tt,et):{}),[F,Ve.join(),et,tt]),ft=e.useMemo((()=>[f(tt,Ve[0]),f(et,Ve[1])]),[tt,et,Ve.join()]),gt=e.useMemo((()=>"x"===a?ft[0]:ft[1]),[a,ft[0],ft[1]]),yt=s(b(ye,re),40),vt=s(b(ve,re,He,Be),40),bt=s(b(be,re),40),xt=e.useCallback(((e,t,r,n)=>{const o=le.current;return o?function(e,t,r,n,o){let l;if(!t&&!n)return null;const i=performance.now(),s=t.scrollTop,c=t.scrollLeft,a=u=>{const d=Math.min((u-i)/r,1);"y"===e?t.scrollTop=s+(n-s)*d:"x"===e&&(t.scrollLeft=c+(n-c)*d),1>d?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,o,r,e,n):null}),[]),Et=e.useCallback(((e,t,r)=>{if(ce.current){if(ce.current!==Ne[0])return void(ce.current=Ne[0])}else ce.current=Ne[0];const n=xt(t,e,ze.duration);n&&r.push(n)}),[Ne[0],ze.duration,xt]),jt=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:C?`${Ie}px ${$e}px ${Xe}px ${We}px`:"",height:Ge[1]&&"none"!==Ge[1]?Ze+"px":"fit-content",width:Ge[0]&&"none"!==Ge[0]?Qe+"px":"fit-content"},X.content&&{cursor:"grab"}),A&&!(null==H?void 0:H.type)&&{gap:`${Ye}px ${Pe}px`}),L&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=l(e,t)+"px";return"x"===t?{minWidth:r}:{minHeight:r}}let i,s;return Array.isArray(e)?[i,s]=e:i=s=e,{minWidth:l(i,"x")+"px",minHeight:l(s,"y")+"px"}}(L,a,Ve,He,Be)),F&&{flexShrink:0});if(null==H?void 0:H.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=Ge[1]?"wrap":void 0,r=1===Je[0]?"y"===a?"column":"row":I;return Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:t,justifyContent:v(N)})}),[C,Re,Se,[Ie,$e,Xe,We,He,Be,Ye,Pe].join(),Ve.join(),Me,Ge[1],Ze,Qe,X.content,Me,null==H?void 0:H.type,a,Je[0],I,N]),wt=e.useCallback((e=>{if(!B)return;const t=()=>((e,t,r,n)=>{e&&e.querySelectorAll(".ms-bar").forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(oe.current,0,e,R);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ae.current)&&t():t()}),[B]),Ot=e.useCallback(((e,t="mousedown",r)=>{const n=e||("scroll"===l?"thumb":"slider");if("wrapp"===e&&!X.content||["thumb","slider"].includes(n)&&!X.progressElement)return;y(l,ne.current,se);let o=null;r&&(o=r.getAttribute("data-direction")),function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>E(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>j(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>{t.preventDefault(),E(Object.assign(Object.assign({},e),{mouseEvent:t}))}),{signal:r,passive:!1}),document.addEventListener("touchend",(r=>j(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:t,scrollElementRef:le.current,objectsWrapperRef:ie.current,scrollBar:r||null,clickedObject:ae,scrollContentRef:oe.current,scrollStateRef:de.current,type:l,scrollBarOnHover:B,mouseOnEl:w,mouseOnRefHandle:wt,triggerUpdate:re,direction:a,smoothScroll:xt,sizeLocal:[Ve[0],Ve[1]],clicked:n,numForSliderRef:pe,isScrollingRef:me,prevCoordsRef:he,thumbSize:"x"===o?at:ct,axisFromAtr:o,duration:ze.duration})}),[a,l,X.content,X.progressElement,Ve.join(),ct,at,ze.duration,xt,wt,B]),St=e.useCallback((e=>{Ot(null,e.type,e.target)}),[Ot]),Rt=e.useCallback((()=>{Ot("wrapp")}),[Ot]),Mt=e.useCallback((e=>{le.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o,duration:l})=>{const i=r[0],s=r[1],c=t.scrollTop,a=t.scrollLeft,u=["top","bottom"].includes(e)?s:i,d=(e,t)=>o(g(e,0,u),t,l);"top"===e&&c>0?d(c-n[1],"y"):"left"===e&&a>0&&d(a-n[0],"x"),"bottom"===e&&c+n[1]!==s?d(c+n[1],"y"):"right"===e&&a+n[0]!==i&&d(a+n[0],"x")})({arrowType:e,scrollElement:le.current,wrapSize:[tt,et],scrollSize:Ve,smoothScroll:xt,duration:ze.duration})}),[Ve.join(),tt,et,ze.duration,xt]),kt=e.useCallback((()=>{y(l,ne.current,se);const e=le.current;oe.current&&e&&0!==se.current.length&&((e,t,r,n)=>{!function(){var o,l,i,s;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".ms-slider-element"))&&void 0!==l?l:[],a=null!==(s=null===(i=t[1])||void 0===i?void 0:i.querySelectorAll(".ms-slider-element"))&&void 0!==s?s:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1];o>=l*r&&l*(r+1)>o?e.classList.add("active"):e.classList.remove("active")}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,se.current,Ve,a)}),[Ve.join(),a,le,oe,l]),Tt=e.useCallback((()=>{ne.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(O)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(O);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),i=new Set(t.current.loaded);o.forEach((e=>i.add(e)));let s=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),s=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(i):o.map((e=>e)),empty:s},r()})(ne.current,ue,re,null==H?void 0:H.type)}),[Ee]),zt=e.useCallback((e=>{(null==Y?void 0:Y.clickTrigger)&&((e,t,r,n)=>{const o=e.target;if(!o.closest(r.selector))return;const l=o.closest(`[${O}]`);l&&l.classList.add("remove"),t("emptyKeys-anim",(()=>{l&&l.classList.remove("remove"),n()}),r.delay||0)})(e,R,Y.clickTrigger,Tt)}),[Oe,Tt]),At=e.useCallback((()=>{const e=le.current;e&&(null==p||p(e.scrollLeft,e.scrollTop),me.current=!0,null==M||M(!0),R("handleScroll-anim",(()=>{me.current=!1,null==M||M(!1),(null==H?void 0:H.type)?re():J()}),200),"slider"===l&&Q(),(null==H?void 0:H.type)||J(),re())}),[p,M,l,null==H?void 0:H.type,Q,Tt]),Ct=g(nt/ut*(Ue-ct),0,Ue-ct),Lt=g(((null===(G=le.current)||void 0===G?void 0:G.scrollLeft)||0)/dt*(Ve[0]-Ve[0]/tt*Ve[0]),0,Ve[0]-at),Ft=e.useCallback((e=>{const t="object"==typeof X.wheel&&X.wheel.changeDirectionKey?X.wheel.changeDirectionKey:"KeyX";e.code!==t||"hybrid"!==a||fe.current||(e.stopPropagation(),fe.current=!0,re())}),[a,JSON.stringify(X.wheel)]),Nt=e.useCallback((e=>{fe.current&&(e.stopPropagation(),fe.current=!1,re())}),[]);e.useEffect((()=>{(Y||(null==H?void 0:H.type))&&(Y||null===ue.current.empty||(ue.current.empty=null),J())}),[Oe,null==H?void 0:H.type,me.current,Ne.join(),Tt]),e.useEffect((()=>{const e=de.current.animationFrameId;return((null==H?void 0:H.type)||M)&&M&&(M(!1),re()),kt(),()=>{e&&cancelAnimationFrame(e),(()=>{for(const e of S.values())clearTimeout(e);S.clear()})()}}),[]),e.useEffect((()=>{const e=le.current;if(!e)return;const t=e=>e.preventDefault(),r="hybrid"===a&&"object"==typeof X.wheel&&X.wheel.changeDirection?"x":a,n="hybrid"===a&&Ze+Be<=Ve[1]||fe.current?["hybrid","y"].includes(r)?"x":"y":r,o=X.wheel?e=>{t(e),function(e,t,r){const n=e.target.closest(".ms-element");n.matches(":focus")||n.focus(),t.animating||(t.targetScrollX=n.scrollLeft,t.targetScrollY=n.scrollTop),"x"===r?t.targetScrollX=g(t.targetScrollX+e.deltaY,0,n.scrollWidth-n.clientWidth+2):t.targetScrollY=g(t.targetScrollY+e.deltaY,0,n.scrollHeight-n.clientHeight+2),t.animating||(t.animating=!0,t.animationFrameId=requestAnimationFrame((function e(){let o=0;"x"===r?(n.scrollLeft+=.4*(t.targetScrollX-n.scrollLeft),o=Math.abs(n.scrollLeft-t.targetScrollX)):(n.scrollTop+=.4*(t.targetScrollY-n.scrollTop),o=Math.abs(n.scrollTop-t.targetScrollY)),o>2.5?t.animationFrameId=requestAnimationFrame(e):(t.animating=!1,null!==t.animationFrameId&&(cancelAnimationFrame(t.animationFrameId),t.animationFrameId=null))})))}(e,de.current,n)}:t;return e.addEventListener("wheel",o,{passive:!1}),()=>{e.removeEventListener("wheel",o)}}),[a,JSON.stringify(X.wheel),Ze,Ve[1],Be,fe.current]),e.useEffect((()=>{if(!ze.value)return;const e=[];return("hybrid"===a?["x","y"]:[a]).forEach((t=>{const r="x"===t?0:1;"end"===ze.value[r]&&Et(t,"x"===t?dt:ut,e)})),()=>{e.forEach((e=>e()))}}),[a,ze.value.join(),xe,ut,dt,tt,et]),e.useEffect((()=>{if(!ze.value)return;const e=[];return("hybrid"===a?["x","y"]:[a]).forEach((t=>{const r="x"===t?0:1;"number"==typeof ze.value[r]&&Et(t,ze.value[r],e)})),()=>{e.forEach((e=>e()))}}),[xe,null==d?void 0:d.updater,a,Et,ze.value.join()]);const It=e.useCallback(((t,r,n,o)=>{var l;const i=Object.assign({width:_e[0]?_e[0]+"px":void 0,height:_e[1]?_e[1]+"px":void 0},(null==H?void 0:H.type)&&Object.assign({position:"absolute",top:r+"px",left:n+"px"},!_e[0]&&1===Je[0]&&{transform:"translateX(-50%)"})),s=P?e.createElement(e.Suspense,{fallback:D},o):o,c=(null===(l=null==Y?void 0:Y.clickTrigger)||void 0===l?void 0:l.selector)&&zt;return e.createElement("div",Object.assign({key:t},H||Y?{[O]:""+t}:{},{className:"ms-object-box",style:i,onClick:c}),s)}),[P,!!D,_e.join(),Ee,Oe,Je[0],zt]),$t=e.createElement("div",{className:"ms-objects-wrapper",ref:ie,onMouseDown:Rt,style:jt},Ne.map(((t,n)=>{var o,l,s;const c=e.Children.toArray(r).find((r=>e.isValidElement(r)&&r.key===t)),u=(null==H?void 0:H.stopLoadOnScroll)&&me.current&&!ue.current.loaded.includes(""+t)?D:(null===(o=ue.current.empty)||void 0===o?void 0:o.includes(t))?"object"==typeof(null==Y?void 0:Y.mode)?Y.mode.fallback:D:c,d="number"==typeof Ge[0]&&"number"==typeof Ge[1]||"firstChild"!==Ge[0]&&"firstChild"!==Ge[1]||0!==n?u:e.createElement(i,{onResize:bt},u);if(!(null==H?void 0:H.type))return It(t,0,0,d);{const{elementTop:e,elementBottom:r,left:o,right:i}=pt[n],c="x"===a?qe:Ke,u=Ue+c>("x"===a?o:e)-nt&&("x"===a?i:r)-nt>0-c,m="hybrid"!==a||Ve[0]+qe>o-((null===(l=le.current)||void 0===l?void 0:l.scrollLeft)||0)&&i-((null===(s=le.current)||void 0===s?void 0:s.scrollLeft)||0)>0-qe;if(u&&m)return It(t,e,o,d)}}))),Xt=[{positionType:"x"===a?"left":"top",visibility:ot},{positionType:"x"===a?"right":"bottom",visibility:lt},..."hybrid"===a?[{positionType:"left",visibility:it},{positionType:"right",visibility:st}]:[]],Wt=e.createElement("div",{"morph-scroll":`〈♦${Z}〉`,className:t,ref:ne,style:{width:Ve[2]+"px",height:Ve[3]+"px"}},e.createElement("div",{className:"ms-content",ref:oe,onMouseEnter:wt,onMouseLeave:wt,onTouchStart:wt,onTouchEnd:wt,style:Object.assign({position:"relative",width:Ve[0]+"px",height:Ve[1]+"px"},X.arrows&&Le.size&&("x"===a?{left:Le.size+"px"}:"y"===a?{top:Le.size+"px"}:{top:Le.size+"px",left:Le.size+"px"}))},e.createElement("div",{className:"ms-element",ref:le,onScroll:At,onKeyDown:Ft,onKeyUp:Nt,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%",outline:"none"},ht),{overflow:null!==(_={x:tt>Ve[0]?"scroll hidden":"hidden",y:et>Ve[1]?"hidden scroll":"hidden",hybrid:`${tt>Ve[0]?"scroll":"hidden"} ${et>Ve[1]?"scroll":"hidden"}`,hide:"hidden"}[X.wheel||X.content?a:"hide"])&&void 0!==_?_:"hidden"}),"scroll"!==l||"boolean"!=typeof X.progressElement||!1===X.progressElement?{scrollbarWidth:"none"}:{})},_e[0]&&_e[1]?$t:e.createElement(i,{onResize:vt,style:Object.assign({},ht)},$t)),$&&Xt.map((({positionType:t,visibility:r})=>e.createElement(m,{key:"edge-"+t,edgeGradient:Ce,visibility:r,edgeType:t}))),X.progressElement&&!0!==X.progressElement&&[{shouldRender:rt>ct,direction:a,thumbSize:ct,thumbSpace:Ct,objLengthPerSize:gt,progressReverseIndex:0},{shouldRender:"hybrid"===a&&tt>at,direction:"x",thumbSize:at,thumbSpace:Lt,objLengthPerSize:ft[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((t=>e.createElement(u,{key:t.direction,type:l,direction:t.direction,progressReverse:"boolean"==typeof W?W:W[t.progressReverseIndex],size:Ve,progressTrigger:X,scrollBarOnHover:B,scrollBarEvent:"sliderMenu"===l?xt:St,thumbSize:t.thumbSize,thumbSpace:t.thumbSpace,objLengthPerSize:t.objLengthPerSize,sliderCheckLocal:kt,duration:ze.duration})))),X.arrows&&Xt.map((({positionType:t,visibility:r})=>e.createElement(h,{key:"arrow-"+t,activity:r,arrows:Le,arrowType:t,handleArrow:Mt,size:"hybrid"===a?Ve[0]+2*Le.size:Ve[0]}))));return"auto"===k?e.createElement(i,{measure:"outer",onResize:yt},Wt):Wt};k.displayName="MorphScroll";const T={MorphScroll:k,ResizeTracker:i,IntersectionTracker:l};export{l as IntersectionTracker,k as MorphScroll,i as ResizeTracker,T as default};
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "morphing-scroll",
3
- "version": "2.2.20",
3
+ "version": "2.3.0",
4
4
  "description": "React library for custom object scrolling and scrollbar styling",
5
5
  "author": "Georg Schilin",
6
6
  "license": "MIT",
7
- "module": "./index.js",
7
+ "main": "cjs/index.js",
8
+ "module": "esm/index.js",
8
9
  "exports": {
9
10
  ".": {
10
- "import": "./index.js",
11
- "types": "./types/index.d.ts"
12
- },
13
- "./package.json": "./package.json"
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
13
+ }
14
14
  },
15
15
  "types": "./types/index.d.ts",
16
16
  "keywords": [
@@ -316,7 +316,6 @@ type MorphScrollT = {
316
316
  * @note
317
317
  * - *`progressElement` can be thumb or slider, use props `type`*
318
318
  * - *If `progressElement` is true and `type` is "scroll", the default browser scroll element will be used*
319
- * - *`arrows` can be designed with their className or you can provide a custom element*
320
319
  *
321
320
  * @example
322
321
  * ```tsx
@@ -328,7 +327,9 @@ type MorphScrollT = {
328
327
  * ```
329
328
  */
330
329
  progressTrigger: {
331
- wheel?: boolean;
330
+ wheel?:
331
+ | boolean
332
+ | { changeDirection?: boolean; changeDirectionKey?: string };
332
333
  content?: boolean;
333
334
  progressElement?: boolean | React.ReactNode;
334
335
  arrows?: boolean | { size?: number; element?: React.ReactNode };
package/index.js DELETED
@@ -1 +0,0 @@
1
- import e,{useMemo as t,useEffect as r,useRef as n}from"react";const o=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;r>t;t++)e.push(n[t%4]);n=e}return n},l=({className:t,children:r,style:n,root:l,threshold:s,rootMargin:i,visibleContent:c=!1,onIntersection:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=e.useMemo((()=>{if(!i)return"";const e=o(i);return`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px`}),[i]),f=e.useCallback((([e])=>{d(e.isIntersecting),a&&a({time:e.time,rootBounds:e.rootBounds,boundingClientRect:e.boundingClientRect,intersectionRect:e.intersectionRect,isIntersecting:e.isIntersecting,intersectionRatio:e.intersectionRatio,target:e.target})}),[a]);return e.useEffect((()=>{const e=new IntersectionObserver(f,{root:l,threshold:s,rootMargin:p});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[f,l,s,p]),e.createElement("div",{"intersection-tracker":"",className:t,ref:m,style:n},c||u?r:null)};l.displayName="IntersectionTracker";const s=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const s=e.useRef(null);e.useEffect((()=>{const e=s.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const i={width:"max-content",height:"max-content"},c={inner:Object.assign({},i),outer:Object.assign({},{width:"100%",height:"100%"}),all:Object.assign({minWidth:"100%",minHeight:"100%"},i)};return e.createElement("div",{"resize-tracker":"",className:t,ref:s,style:Object.assign(Object.assign({willChange:"width, height"},c[o]),n)},r)};function i(e,n){const o=t((()=>function(e,t){let r=null,n=null;const o=(...o)=>{"requestFrame"===t?(null!==n&&cancelAnimationFrame(n),n=requestAnimationFrame((()=>{e(...o),n=null}))):(null!==r&&clearTimeout(r),r=setTimeout((()=>{e(...o),r=null}),t))};return o.cancel=()=>{null!==r&&(clearTimeout(r),r=null),null!==n&&(cancelAnimationFrame(n),n=null)},o}(e,n)),[n,e]);return r((()=>()=>{o.cancel()}),[o]),o}s.displayName="ResizeTracker";let c=1;const a=({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:s,scrollBarEvent:i,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d,duration:m})=>{const p="sliderMenu"!==t?{onMouseDown:i,onTouchStart:i}:{},f=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",s="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"ms-slider-element",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{i(s*o,n,m,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,i,null==l?void 0:l.progressElement]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:o[0]+"px"},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),0!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign({height:c+"px",willChange:"transform, height",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"}),{transition:"height 0.05s ease-in-out"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),f))};a.displayName="ScrollBar";var u=e.memo(a);const d=({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:t.size+"px",top:0}:{width:"100%",height:t.size+"px",left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?" "+n:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})};d.displayName="Edge";var m=e.memo(d);const p=({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:r.size+"px"},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:l+"px"}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},s),onClick:()=>o(n)},r.element)};p.displayName="Arrow";var f=e.memo(p);function h(e,t){return e>t?Math.floor(e/t):1}function g(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const v=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)},y=e=>e?"start"===e?"flex-start":"center"===e?"center":"flex-end":void 0;function b(e,t,r=0,n=0){return o=>{var l,s,i,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(s=o.height)&&void 0!==s?s:0)-n};(null===(i=e.current)||void 0===i?void 0:i.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function x(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(t+"");else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function E(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,s={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const i=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:s.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:s.y,o=e.scrollElementRef;if("thumb"===e.clicked){const s=e.objectsWrapperRef,i=getComputedStyle(s),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?s.clientWidth+parseFloat(i.marginLeft)+parseFloat(i.marginRight):s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom),u=c-e.thumbSize,d=a-c;if(0>=u||0>=d)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),f=m-p;e.prevCoordsRef.current.leftover=f,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=s[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],i="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&i>c+l?e.smoothScroll(c+l,t,e.duration):0>o&&c>0&&e.smoothScroll(c-l,t,e.duration),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?i(t):"wrapp"===e.clicked?"slider"===e.type?c(t):i(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function j(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const O=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},w="wrap-id",S=new Map,R=(e,t,r)=>{M(e);const n=setTimeout((()=>{t(),S.delete(e)}),r);S.set(e,n)},M=e=>{const t=S.get(e);t&&(clearTimeout(t),S.delete(e))},k=({type:t="scroll",className:r,size:l,objectsSize:a,direction:d="y",gap:p,wrapperMargin:M,wrapperMinSize:k,progressReverse:T=!1,progressTrigger:z={wheel:!0},scrollBarOnHover:A=!1,suspending:C=!1,fallback:L,scrollPosition:F,edgeGradient:N,children:I,onScrollValue:$,elementsAlign:W,elementsDirection:X="row",wrapperAlign:B,isScrolling:H,render:Y,emptyElements:q,crossCount:P})=>{var D,V,K,G,U,_,J;const Q=i((()=>{kt()}),40),Z=i((()=>{vt()}),34),ee=function(){const e=n(null);return null===e.current&&(e.current=""+c++),e.current}();if(!l)throw Error(`Prop "size" is not provided\nMorphScroll〈♦${ee}〉`);Object.keys(z).length;const[te,re]=e.useState(0),ne=()=>{re((e=>"number"==typeof e&&1e3>e?e+1:0))},oe=e.useRef(null),le=e.useRef(null),se=e.useRef(null),ie=e.useRef(null),ce=e.useRef([]),ae=e.useRef(null),ue=e.useRef("none"),de=e.useRef({loaded:[],empty:[]}),me=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),pe=e.useRef(!1),fe=e.useRef(0),he=e.useRef(null);function ge(){return e.useRef({width:0,height:0})}const ve=ge(),ye=ge(),be=ge(),[xe,Ee,je,Oe,we,Se,Re,Me]=function(...e){return e.map(x)}(null==F?void 0:F.value,Y,l,a,q,k,B,p),ke=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==F?void 0:F.value)||"string"==typeof(null==F?void 0:F.value)?[F.value,F.value]:null!==(e=null==F?void 0:F.value)&&void 0!==e?e:[null],duration:null!==(t=null==F?void 0:F.duration)&&void 0!==t?t:200}}),[xe,null==F?void 0:F.duration]),Te={color:null,size:40},ze=e.useMemo((()=>"object"==typeof N?Object.assign(Object.assign({},Te),N):Te),[N]),Ae=e.useMemo((()=>Object.assign(Object.assign({},Te),"object"==typeof z.arrows?z.arrows:{})),[z.arrows]),Ce=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap(Ce):[r]}return[t]}),[]),Le=e.useMemo((()=>e.Children.toArray(I).flatMap(Ce).map((t=>e.isValidElement(t)&&t.key?t.key+"":null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==q?void 0:q.mode)||!(null===(t=de.current.empty)||void 0===t?void 0:t.includes(e))}))),[I,we,null===(D=de.current.empty)||void 0===D?void 0:D.join()]),[Fe,Ne,Ie,$e]=M?o(M):[0,0,0,0],We=Fe+Ie,Xe=$e+Ne,[Be,He]=e.useMemo((()=>{var e,t;return"number"==typeof p?[p,p]:Array.isArray(p)?[null!==(e=p[1])&&void 0!==e?e:0,null!==(t=p[0])&&void 0!==t?t:0]:[0,0]}),[p]),Ye=e.useMemo((()=>o((null==Y?void 0:Y.rootMargin)||0,"x"===d)),[Ee,d]),[qe,Pe]=Ye?[Ye[2],Ye[0]]:[0,0],De=e.useMemo((()=>{const[e,t]=Array.isArray(l)?l:"number"==typeof l?[l,l]:[ve.current.width,ve.current.height];if(!z.arrows||!Ae.size)return[e,t,e,t];const r=2*Ae.size;let n=e,o=t;return"x"===d?n=e-r:"y"===d?o=t-r:"hybrid"===d&&(n=e-r,o=t-r),[n,o,e,t]}),[je,Ae.size,ve.current]),Ve="x"===d?De[0]:De[1],Ke=e.useMemo((()=>a?Array.isArray(a)?a:o(a,!0,2):[null,null]),[Oe]),Ge=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(Ke[0]&&"none"!==Ke[0]&&"size"!==Ke[0]?Ke[0]:"y"===d&&"none"!==Ke[0]||"size"===Ke[0]?De[0]:0,be.current.width),e(Ke[1]&&"none"!==Ke[1]&&"size"!==Ke[1]?Ke[1]:"x"===d&&"none"!==Ke[1]||"size"===Ke[1]?De[1]:0,be.current.height)]}),[Oe,je,be.current,De.join()]),Ue=e.useMemo((()=>{const e="x"===d,t="row"===X,r="column"===X,n=e?De[1]:De[0],o=e?Ge[1]+He:Ge[0]+Be,l="hybrid"===d?o*(Le.length+1)-o:n,s=Math.floor(l/o)||1,i=P&&s>=P?"hybrid"===d?Math.ceil(s/P):P:s,c=i>1&&i<Le.length?Math.ceil(Le.length/i):i>Le.length?1:Le.length,a=P&&P<Le.length,u=e=>Number.isFinite(e)&&e>0?e:1;if("hybrid"===d){const e=a?t?P:i:t?Le.length:1,n=a?r?P:i:r?Le.length:1;return[u(e),u(n)]}return[u(i),u(c)]}),[Le.length,d,Ge.join(),De.join(),Be,Xe,We,P]),_e=e.useMemo((()=>{const e=Ue[0]?Ue[0]*He-He:0,t="x"===d?Ue[1]:Ue[0];return Ge[0]?(Ge[0]+He)*t-He:(null==Y?void 0:Y.type)?be.current.width+e:ye.current.width}),[Ge[0],Ue.join(),He,ye.current.width,be.current,Ee]),Je=e.useMemo((()=>{const e=1>Ue[1]?1:Ue[0]*Be-Be;return Ge[1]?"x"===d?(Ge[1]+Be)*Ue[0]-Be:(Ge[1]+Be)*Ue[1]-Be:(null==Y?void 0:Y.type)?be.current.height+e:ye.current.height}),[Ge[1],Ue.join(),Be,ye.current.height,be.current,Ee]),Qe=e.useMemo((()=>Je+We),[Je,We]),Ze=e.useMemo((()=>_e+Xe),[_e,Xe]),et="x"===d?Ze:Qe,tt="x"===d?(null===(V=se.current)||void 0===V?void 0:V.scrollLeft)||0:(null===(K=se.current)||void 0===K?void 0:K.scrollTop)||0,rt=tt>1&&!0,nt=et>Math.round(tt+Ve);let ot=!1,lt=!1;"hybrid"===d&&(ot=((null===(G=se.current)||void 0===G?void 0:G.scrollLeft)||0)>1&&!0,lt=Math.round(((null===(U=se.current)||void 0===U?void 0:U.scrollLeft)||0)+De[0])<Ze);const st=e.useMemo((()=>{if(!z.progressElement||!et)return 0;const e=Math.round(Ve/et*Ve);return!Number.isFinite(e)||0>e?0:e}),[Ve,et,z.progressElement]),it=e.useMemo((()=>{if(!z.progressElement)return 0;const e=Math.round(De[0]/Ze*De[0]);return!Number.isFinite(e)||0>e?0:e}),[De[0],Ze,z.progressElement]),ct=e.useMemo((()=>Ve?et-Ve:et),[et,Ve]),at=e.useMemo((()=>De[0]?Ze-De[0]:Ze),[Ze,De[0]]),ut=e.useCallback((()=>{if(!(null==Y?void 0:Y.type)||1>=Ue[0])return[];const e=Array.from({length:Le.length},((e,t)=>t)),t=Array.from({length:Ue[0]},(()=>[])),r="x"===d&&"column"===X||"x"!==d&&"row"===X;return e.forEach((e=>{const n=r?e%Ue[0]:Math.floor(e/Ue[1]);t[n]&&t[n].push(e)})),t}),[Le.length,Ue.join(),Ee,X,d]),dt=e.useMemo((()=>{if(!(null==Y?void 0:Y.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if(W){const r=Array.from({length:Le.length},((e,t)=>t)),n=Math.abs(Math.floor(Le.length/Ue[0])*Ue[0]-Le.length);e=n?r.slice(-n):[],"center"===W?t=(Ge[0]+He)*(Ue[0]-n)/2:"end"===W&&(t=(Ge[0]+He)*(Ue[0]-n))}return Le.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n)return["x"===d?n:r,["hybrid","y"].includes(d)?n:r]}return[0,0]}(n,ut()),l=e.length>0&&e.includes(n)?t:0,s=function(e){const t="x"===d?l:0;return e>0?t+(Ge[1]+Be)*e:t}(Ue[0]>1||["hybrid","x"].includes(d)?o[1]:n),i=Ge[1]?s+Ge[1]:s,c=function(e){const t="x"===d?0:l;return e>0?t+(Ge[0]+He)*e:t}(1===Ue[0]&&"x"===d?n:o[0]);return{elementTop:s,elementBottom:i,left:c,right:c+Ge[0]}}))}),[I,Ge.join(),p,Ee,Ue[0],X]),mt=e.useMemo((()=>(null==De?void 0:De.length)&&B?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,s={display:"flex"};return t[0]>r&&(s.justifyContent=y(o)),t[1]>n&&(s.alignItems=y(l)),s}(B,De,Ze,Qe):{}),[B,De.join(),Qe,Ze]),pt=e.useMemo((()=>[h(Ze,De[0]),h(Qe,De[1])]),[Ze,Qe,De.join()]),ft=e.useMemo((()=>"x"===d?pt[0]:pt[1]),[d,pt[0],pt[1]]),ht=e.useCallback((e=>{if(!A)return;const t=()=>((e,t,r,n)=>{e&&e.querySelectorAll(".ms-bar").forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(le.current,0,e,R);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ue.current)&&t():t()}),[A,t,ue.current,le.current]),gt=e.useCallback((e=>{se.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o,duration:l})=>{const s=r[0],i=r[1],c=t.scrollTop,a=t.scrollLeft,u=["top","bottom"].includes(e)?i:s,d=(e,t)=>o(g(e,0,u),t,l);"top"===e&&c>0?d(c-n[1],"y"):"left"===e&&a>0&&d(a-n[0],"x"),"bottom"===e&&c+n[1]!==i?d(c+n[1],"y"):"right"===e&&a+n[0]!==s&&d(a+n[0],"x")})({arrowType:e,scrollElement:se.current,wrapSize:[Ze,Qe],scrollSize:De,smoothScroll:wt,duration:ke.duration})}),[se.current,De.join(),Ze,Qe,ke.duration]),vt=e.useCallback((()=>{v(t,oe.current,ce);const e=se.current;le.current&&e&&0!==ce.current.length&&((e,t,r,n)=>{!function(){var o,l,s,i;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".ms-slider-element"))&&void 0!==l?l:[],a=null!==(i=null===(s=t[1])||void 0===s?void 0:s.querySelectorAll(".ms-slider-element"))&&void 0!==i?i:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1];o>=l*r&&l*(r+1)>o?e.classList.add("active"):e.classList.remove("active")}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,ce.current,De,d)}),[De.join(),d,se,le,ce,t]),yt=e.useCallback((()=>{const e=se.current;e&&(null==$||$(e.scrollLeft,e.scrollTop),pe.current=!0,null==H||H(!0),R("handleScroll-anim",(()=>{pe.current=!1,null==H||H(!1),(null==Y?void 0:Y.type)?ne():Q()}),200),"slider"===t&&Z(),(null==Y?void 0:Y.type)||Q(),ne())}),[d,$,H,Ee,t,Z]),bt=g(tt/ct*(Ve-st),0,Ve-st),xt=g(((null===(_=se.current)||void 0===_?void 0:_.scrollLeft)||0)/at*(De[0]-De[0]/Ze*De[0]),0,De[0]-it),Et=i(b(ve,ne),40),jt=i(b(ye,ne,Xe,We),40),Ot=i(b(be,ne),40),wt=e.useCallback(((e,t,r,n)=>{const o=se.current;return o?function(e,t,r,n,o){let l;if(!t&&!n)return null;const s=performance.now(),i=t.scrollTop,c=t.scrollLeft,a=u=>{const d=Math.min((u-s)/r,1);"y"===e?t.scrollTop=i+(n-i)*d:"x"===e&&(t.scrollLeft=c+(n-c)*d),1>d?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,o,r,e,n):null}),[se]),St=e.useCallback(((e,r="mousedown",n)=>{const o=e||("scroll"===t?"thumb":"slider");if("wrapp"===e&&!z.content||["thumb","slider"].includes(o)&&!z.progressElement)return;v(t,oe.current,ce);let l=null;n&&(l=n.getAttribute("data-direction")),function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>E(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>j(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>{t.preventDefault(),E(Object.assign(Object.assign({},e),{mouseEvent:t}))}),{signal:r,passive:!1}),document.addEventListener("touchend",(r=>j(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:r,scrollElementRef:se.current,objectsWrapperRef:ie.current,scrollBar:n||null,clickedObject:ue,scrollContentRef:le.current,scrollStateRef:me.current,type:t,scrollBarOnHover:A,mouseOnEl:O,mouseOnRefHandle:ht,triggerUpdate:ne,direction:d,smoothScroll:wt,sizeLocal:[De[0],De[1]],clicked:o,numForSliderRef:fe,isScrollingRef:pe,prevCoordsRef:he,thumbSize:"x"===l?it:st,axisFromAtr:l,duration:ke.duration})}),[t,z.content,z.progressElement,De.join(),st,it,ke.duration]),Rt=e.useCallback((e=>{St(null,e.type,e.target)}),[St]),Mt=e.useCallback((()=>{St("wrapp")}),[St]),kt=e.useCallback((()=>{oe.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(w)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(w);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),s=new Set(t.current.loaded);o.forEach((e=>s.add(e)));let i=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),i=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(s):o.map((e=>e)),empty:i},r()})(oe.current,de,ne,null==Y?void 0:Y.type)}),[Ee]),Tt=e.useCallback((e=>{(null==q?void 0:q.clickTrigger)&&((e,t,r,n)=>{e.target.closest(r.selector)&&t("emptyKeys-anim",(()=>{n()}),r.delay||0)})(e,R,q.clickTrigger,kt)}),[we]),zt=e.useCallback(((e,t,r)=>{if(ae.current){if(ae.current!==Le[0])return void(ae.current=Le[0])}else ae.current=Le[0];const n=wt(t,e,ke.duration);n&&r.push(n)}),[Le[0],ke.duration]),At=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:M?`${Fe}px ${Ne}px ${Ie}px ${$e}px`:"",height:Ke[1]&&"none"!==Ke[1]?Je+"px":"fit-content",width:Ke[0]&&"none"!==Ke[0]?_e+"px":"fit-content"},z.content&&{cursor:"grab"}),p&&!(null==Y?void 0:Y.type)&&{gap:`${Be}px ${He}px`}),k&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=l(e,t)+"px";return"x"===t?{minWidth:r}:{minHeight:r}}let s,i;return Array.isArray(e)?[s,i]=e:s=i=e,{minWidth:l(s,"x")+"px",minHeight:l(i,"y")+"px"}}(k,d,De,Xe,We)),B&&{flexShrink:0});if(null==Y?void 0:Y.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=Ke[1]?"wrap":void 0,r=1===Ue[0]?"y"===d?"column":"row":X;return Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:t,justifyContent:y(W)})}),[M,[Fe,Ne,Ie,$e,Xe,We].join(),Ke[1],Je,_e,z.content,Me,[Be,He].join(),null==Y?void 0:Y.type,Se,d,De.join(),Re,Ue[0],X,W]);e.useEffect((()=>{(q||(null==Y?void 0:Y.type))&&(q||null===de.current.empty||(de.current.empty=null),Q())}),[we,null==Y?void 0:Y.type,Ee,pe.current,Le.length]),e.useEffect((()=>(((null==Y?void 0:Y.type)||H)&&(H&&H(!1),ne()),vt(),()=>{me.current.animationFrameId&&cancelAnimationFrame(me.current.animationFrameId),(()=>{for(const e of S.values())clearTimeout(e);S.clear()})()})),[]),e.useEffect((()=>{const e=se.current;if(!e)return;const t=z.wheel?t=>function(e,t,r,n){e.preventDefault(),r.animating||(r.targetScrollX=t.scrollLeft,r.targetScrollY=t.scrollTop),"x"===n?r.targetScrollX=g(r.targetScrollX+e.deltaY,0,t.scrollWidth-t.clientWidth+2):r.targetScrollY=g(r.targetScrollY+e.deltaY,0,t.scrollHeight-t.clientHeight+2),r.animating||(r.animating=!0,r.animationFrameId=requestAnimationFrame((function e(){let o=0;"x"===n?(t.scrollLeft+=.4*(r.targetScrollX-t.scrollLeft),o=Math.abs(t.scrollLeft-r.targetScrollX)):(t.scrollTop+=.4*(r.targetScrollY-t.scrollTop),o=Math.abs(t.scrollTop-r.targetScrollY)),o>2.5?r.animationFrameId=requestAnimationFrame(e):(r.animating=!1,null!==r.animationFrameId&&(cancelAnimationFrame(r.animationFrameId),r.animationFrameId=null))})))}(t,e,me.current,d):e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}}),[d,z.wheel]),e.useEffect((()=>{if(!ke.value)return;const e=[];return("hybrid"===d?["x","y"]:[d]).forEach((t=>{const r="x"===t?0:1;"end"===ke.value[r]&&zt(t,"x"===t?at:ct,e)})),()=>{e.forEach((e=>e()))}}),[ke.value.join(),xe,ct,at,Ze,Qe]),e.useEffect((()=>{if(!ke.value)return;const e=[];return("hybrid"===d?["x","y"]:[d]).forEach((t=>{const r="x"===t?0:1;"number"==typeof ke.value[r]&&zt(t,ke.value[r],e)})),()=>{e.forEach((e=>e()))}}),[xe,null==F?void 0:F.updater]);const Ct=e.useCallback(((t,r,n,o)=>{var l;const s=Object.assign({width:Ge[0]?Ge[0]+"px":void 0,height:Ge[1]?Ge[1]+"px":void 0},(null==Y?void 0:Y.type)&&Object.assign({position:"absolute",top:r+"px",left:n+"px"},!Ge[0]&&1===Ue[0]&&{transform:"translateX(-50%)"})),i=C?e.createElement(e.Suspense,{fallback:L},o):o,c=(null===(l=null==q?void 0:q.clickTrigger)||void 0===l?void 0:l.selector)&&Tt;return e.createElement("div",Object.assign({key:t},Y||q?{[w]:""+t}:{},{className:"ms-object-box",style:s,onClick:c}),i)}),[C,!!L,Ge.join(),se.current,Ee,we,Ue[0]]),Lt=e.createElement("div",{className:"ms-objects-wrapper",ref:ie,onMouseDown:Mt,style:At},Le.map(((t,r)=>{var n,o,l;const i=e.Children.toArray(I).find((r=>e.isValidElement(r)&&r.key===t)),c=(null==Y?void 0:Y.stopLoadOnScroll)&&pe.current&&!de.current.loaded.includes(""+t)?L:(null===(n=de.current.empty)||void 0===n?void 0:n.includes(t))?"object"==typeof(null==q?void 0:q.mode)?q.mode.fallback:L:i,a="number"==typeof Ke[0]&&"number"==typeof Ke[1]||"firstChild"!==Ke[0]&&"firstChild"!==Ke[1]||0!==r?c:e.createElement(s,{onResize:Ot},c);if(!(null==Y?void 0:Y.type))return Ct(t,0,0,a);{const{elementTop:e,elementBottom:n,left:s,right:i}=dt[r],c="x"===d?qe:Pe,u=Ve+c>("x"===d?s:e)-tt&&("x"===d?i:n)-tt>0-c,m="hybrid"!==d||De[0]+qe>s-((null===(o=se.current)||void 0===o?void 0:o.scrollLeft)||0)&&i-((null===(l=se.current)||void 0===l?void 0:l.scrollLeft)||0)>0-qe;if(u&&m)return Ct(t,e,s,a)}}))),Ft=[{positionType:"x"===d?"left":"top",visibility:rt},{positionType:"x"===d?"right":"bottom",visibility:nt},..."hybrid"===d?[{positionType:"left",visibility:ot},{positionType:"right",visibility:lt}]:[]],Nt=e.createElement("div",{"morph-scroll":`〈♦${ee}〉`,className:r,ref:oe,style:{width:De[2]+"px",height:De[3]+"px"}},e.createElement("div",{className:"ms-content",ref:le,onMouseEnter:ht,onMouseLeave:ht,onTouchStart:ht,onTouchEnd:ht,style:Object.assign({position:"relative",width:De[0]+"px",height:De[1]+"px"},z.arrows&&Ae.size&&("x"===d?{left:Ae.size+"px"}:"y"===d?{top:Ae.size+"px"}:{top:Ae.size+"px",left:Ae.size+"px"}))},e.createElement("div",{className:"ms-element",ref:se,onScroll:yt,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%"},mt),{overflow:null!==(J={x:Ze>De[0]?"scroll hidden":"hidden",y:Qe>De[1]?"hidden scroll":"hidden",hybrid:`${Ze>De[0]?"scroll":"hidden"} ${Qe>De[1]?"scroll":"hidden"}`,hide:"hidden"}[z.wheel||z.content?d:"hide"])&&void 0!==J?J:"hidden"}),"scroll"!==t||"boolean"!=typeof z.progressElement||!1===z.progressElement?{scrollbarWidth:"none"}:{})},Ge[0]&&Ge[1]?Lt:e.createElement(s,{onResize:jt,style:Object.assign({},mt)},Lt)),N&&Ft.map((({positionType:t,visibility:r})=>e.createElement(m,{key:"edge-"+t,edgeGradient:ze,visibility:r,edgeType:t}))),z.progressElement&&!0!==z.progressElement&&[{shouldRender:et>st,direction:d,thumbSize:st,thumbSpace:bt,objLengthPerSize:ft,progressReverseIndex:0},{shouldRender:"hybrid"===d&&Ze>it,direction:"x",thumbSize:it,thumbSpace:xt,objLengthPerSize:pt[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((r=>e.createElement(u,{key:r.direction,type:t,direction:r.direction,progressReverse:"boolean"==typeof T?T:T[r.progressReverseIndex],size:De,progressTrigger:z,scrollBarOnHover:A,scrollBarEvent:"sliderMenu"===t?wt:Rt,thumbSize:r.thumbSize,thumbSpace:r.thumbSpace,objLengthPerSize:r.objLengthPerSize,sliderCheckLocal:vt,duration:ke.duration})))),z.arrows&&Ft.map((({positionType:t,visibility:r})=>e.createElement(f,{key:"arrow-"+t,activity:r,arrows:Ae,arrowType:t,handleArrow:gt,size:"hybrid"===d?De[0]+2*Ae.size:De[0]}))));return"auto"===l?e.createElement(s,{measure:"outer",onResize:Et},Nt):Nt};k.displayName="MorphScroll";const T={MorphScroll:k,ResizeTracker:s,IntersectionTracker:l};export{l as IntersectionTracker,k as MorphScroll,s as ResizeTracker,T as default};