morphing-scroll 2.5.3 → 2.7.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
@@ -7,16 +7,13 @@
7
7
  - [About](#-about-)
8
8
  - [Installation](#-installation-)
9
9
  - [API](#-api-)
10
- - [MorphScroll](#-morphscroll)
11
- - [Resizetracker](#-resizetracker)
12
- - [Intersectiontracker](#-intersectiontracker)
13
10
  - [License](#-license-)
14
11
 
15
12
  <h2></h2>
16
13
 
17
14
  ### 〈 About 〉
18
15
 
19
- `morphing-scroll` is a `React` is a React library originally created to address common limitations of the native browser scrollbar, including:
16
+ `morphing-scroll` is a `React` library originally created to address common limitations of the native browser scrollbar, including:
20
17
 
21
18
  - Design customization constraints
22
19
  - Cross-browser compatibility
@@ -51,10 +48,9 @@ import Morph from "morphing-scroll";
51
48
  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
49
 
53
50
  > **✦ Note:**
54
- > `MorphScroll` supports both **ESM** and **CommonJS** builds:
51
+ > `MorphScroll` supports both **ESM** (`import`) and **CommonJS** (`require`) builds.
55
52
  >
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
53
+ > This library is currently under development. APIs and behavior may change in future releases.
58
54
 
59
55
  <h2></h2>
60
56
 
@@ -62,22 +58,17 @@ Start using the `MorphScroll` component by defining the required `size` prop. Fo
62
58
 
63
59
  <ul><div>
64
60
 
65
- #### MorphScroll
66
-
67
- `MorphScroll` is the main component of the library responsible for displaying your data.
61
+ <details><summary><b>MorphScroll</b>: <em>main component of the library responsible for displaying your data</em></summary>
68
62
 
69
63
  - #### Props:
70
64
 
71
65
  <ul><div>
72
66
 
73
- ##### **GENERAL SETTINGS**:
67
+ ###### **— GENERAL SETTINGS —**
74
68
 
75
- <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
76
- <b>Type:</b><br />
77
- string<br />
78
- <br />
79
- <b>Description:</b> <em><br />
80
- This parameter allows you to add additional classes to the component.</em><br />
69
+ <details><summary><b><code>className</code></b></summary><br /><ul><div>
70
+ <b>Description:</b><em><br />
71
+ allows you to add additional classes to the component.</em><br />
81
72
  <br />
82
73
  <b>Example:</b>
83
74
 
@@ -91,15 +82,12 @@ This parameter allows you to add additional classes to the component.</em><br />
91
82
 
92
83
  <h2></h2>
93
84
 
94
- <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
95
- <b>Type:</b><br />
96
- React.ReactNode<br />
97
- <br />
98
- <b>Description:</b> <em><br />
99
- This is where you can pass your list elements.<br />
85
+ <details><summary><b><code>children</code></b></summary><br /><ul><div>
86
+ <b>Description:</b><em><br />
87
+ allows to add custom content to the component.<br />
100
88
  Make sure to provide unique keys for each list item, as per React's rules. The <code>MorphScroll</code> component ensures that the cells it generates will use the same keys as your list items, allowing it to render the correct cells for the current list.<br />
101
- Additionally, <code>MorphScroll</code> handles a passed <mark>null</mark> value the same way as <mark>undefined</mark>, rendering nothing in both cases.</em><br />
102
- <br />
89
+ Additionally, <code>MorphScroll</code> handles a passed <b>null</b> value the same way as <b>undefined</b>, rendering nothing in both cases.<br />
90
+ </em><br />
103
91
  <b>Example:</b>
104
92
 
105
93
  ```tsx
@@ -110,24 +98,30 @@ Additionally, <code>MorphScroll</code> handles a passed <mark>null</mark> value
110
98
 
111
99
  <h2></h2>
112
100
 
113
- ##### **SCROLL SETTINGS**:
101
+ ###### **— SCROLL SETTINGS —**
102
+
103
+ <details><summary><b><code>type</code></b></summary><br /><ul><div>
104
+ <b>Usage:</b><br />
105
+
106
+ ```tsx
107
+ type: "slider"; // or "scroll" | "sliderMenu"
108
+ ```
114
109
 
115
- <details><summary><b><code>type</code></b>: <em>Type of progress element.</em></summary><br /><ul><div>
116
- <b>Type:</b><br />
117
- "scroll" | "slider" | "sliderMenu"<br />
118
- <br />
119
110
  <b>Default:</b><br />
120
111
  "scroll"<br />
121
112
  <br />
122
- <b>Description:</b> <em><br />
123
- This parameter defines how the provided <code>progressElement</code> behaves within <code>progressTrigger</code> and how you interact with it.<br />
113
+ <b>Description:</b><em><br />
114
+ defines how the provided <code>progressElement</code> behaves within <code>progressTrigger</code> and how you interact with it.<br />
124
115
  <br />
125
- <mark>scroll</mark> - This is the default value and represents a standard scrollbar.<br />
116
+ <code><b>scroll</b></code>:<br />
117
+ the default value and represents a standard scrollbar.<br />
126
118
  <br />
127
- <mark>slider</mark> - It displays distinct elements indicating the number of full scroll steps within the list.<br />
128
- <br />
129
- <mark>sliderMenu</mark> - It behaves like a <code>slider</code>, but now the <code>progressElement</code> is a menu, an you can provide custom buttons as an array in the <code>progressElement</code>.</em><br />
119
+ <code><b>slider</b></code>:<br />
120
+ displays distinct elements indicating the number of full scroll steps within the list.<br />
130
121
  <br />
122
+ <code><b>sliderMenu</b></code>:<br />
123
+ like <code>slider</code>, but the <code>progressElement</code> is a menu, an you can provide custom buttons as an array in the <code>progressElement</code>.<br />
124
+ </em><br />
131
125
  <b>Example:</b>
132
126
 
133
127
  ```tsx
@@ -142,15 +136,18 @@ This parameter defines how the provided <code>progressElement</code> behaves wit
142
136
 
143
137
  <h2></h2>
144
138
 
145
- <details><summary><b><code>direction</code></b>: <em>Scrolling direction.</em></summary><br /><ul><div>
146
- <b>Type:</b><br />
147
- "x" | "y" | "hybrid"<br />
148
- <br />
139
+ <details><summary><b><code>direction</code></b></summary><br /><ul><div>
140
+ <b>Usage:</b><br />
141
+
142
+ ```tsx
143
+ size: "x"; // or "y" | "hybrid"
144
+ ```
145
+
149
146
  <b>Default:</b><br />
150
147
  "y"<br />
151
148
  <br />
152
- <b>Description:</b> <em><br />
153
- This parameter changes the scroll or slider type direction based on the provided value.<br />
149
+ <b>Description:</b><em><br />
150
+ changes the scroll or slider type direction based on the provided value.<br />
154
151
  You can set the value to horizontal, vertical or hybrid positions to customize the component according to your needs.</em><br />
155
152
  <br />
156
153
  <b>Example:</b>
@@ -167,42 +164,54 @@ You can set the value to horizontal, vertical or hybrid positions to customize t
167
164
 
168
165
  <h2></h2>
169
166
 
170
- <details><summary><b><code>scrollPosition</code></b>: <em>Scroll position and additional options.</em></summary><br /><ul><div>
171
- <b>Type:</b><br />
172
- {<br />
167
+ <details><summary><b><code>scrollPosition</code></b></summary><br /><ul><div>
168
+ <b>Usage:</b><br />
169
+
173
170
  <ul>
174
- value: number | "end" | (number | "end")[];<br />
175
- duration?: number;<br />
176
- updater?: boolean;<br />
171
+ <li><b>Simple</b>:<br />
172
+
173
+ ```tsx
174
+ scrollPosition: 10; // or "end" | null | array if direction="hybrid"
175
+ ```
176
+
177
+ </li>
178
+ <li><b>Advanced</b>:<br />
179
+
180
+ ```tsx
181
+ scrollPosition: {
182
+ value: 10; // or "end" | null | array if direction="hybrid"
183
+ duration: 400;
184
+ updater: true;
185
+ }
186
+ ```
187
+
188
+ </li>
177
189
  </ul>
178
- }<br />
179
- <br />
190
+
180
191
  <b>Default:</b><br />
181
192
  { duration: 200; updater: false }<br />
182
193
  <br />
183
- <b>Description:</b> <em><br />
184
- This parameter allows you to set custom scroll values.<br />
194
+ <b>Description:</b><em><br />
195
+ allows you to set custom scroll values.<br />
185
196
  <br />
186
- <code>value</code>:<br />
197
+ <code><b>value</b></code>:<br />
198
+
187
199
  <ul>
188
- <li><mark>number</mark> - Sets the scroll position to a specific value.</li>
189
- <li><mark>"end"</mark> - Scrolls to the bottom of the list upon loading, which is useful for scenarios like chat message lists. When new elements are appended to the list, the scroll position will update automatically. However, to prevent unwanted scrolling when adding elements to the beginning of the list, this property will not trigger.</li>
200
+ <li><b>number</b> - Sets position to a specific value.</li>
201
+ <li><b>"end"</b> - Sets position to the end of the list.</li>
190
202
  </ul>
191
- You can also provide an array of two values to specific positions ( e.g., [ x, y ] axes ) for hybrid directions.</code>.<br />
203
+ You can also provide an array of two values to specific positions ( e.g., [ x, y ] axes ) for hybrid directions.</code><br />
192
204
  <br />
193
- <code>duration</code>:<br />
194
- This property determines the animation speed for scrolling in <b>ms</b>.<br />
205
+ <code><b>duration</b></code>:<br />
206
+ property determines the animation speed for scrolling in <b>ms</b>.<br />
195
207
  <br />
196
- <code>updater</code>:<br />
197
- This property is a helper for the <code>value</code> property. When setting the same scroll value repeatedly (e.g., clicking a button to scroll to the top), React does not register the update. To force an update, toggle updater within setState, e.g.,<br />
198
- <code>setScroll((prev) => ({ ...prev, value: 0, updater: <b>!prev.updater</b> }))</code></em><br />
208
+ <code><b>updater</b></code>:<br />
209
+ property is a helper for the <code>value</code>. When setting the same scroll value repeatedly, React does not register the update and you can use it to force an update</em><br />
199
210
  <br />
200
211
  <b>Example:</b>
201
212
 
202
213
  ```tsx
203
- <MorphScroll {...props}
204
- scrollPosition={{ value: 100; duration: 100 }}
205
- >
214
+ <MorphScroll {...props} scrollPosition={100}>
206
215
  {children}
207
216
  </MorphScroll>
208
217
  ```
@@ -213,12 +222,9 @@ This property is a helper for the <code>value</code> property. When setting the
213
222
 
214
223
  <h2></h2>
215
224
 
216
- <details><summary><b><code>onScrollValue</code></b>: <em>Callback for scroll value.</em></summary><br /><ul><div>
217
- <b>Type:</b><br />
218
- ( left: number, top: number ) => void<br />
219
- <br />
220
- <b>Description:</b> <em><br />
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 />
225
+ <details><summary><b><code>onScrollValue</code></b></summary><br /><ul><div>
226
+ <b>Description:</b><em><br />
227
+ accepts a callback function that is triggered on every scroll event. The callback receives the current scroll top and left position as a <b>number</b>. The return value of the callback can be used to determine custom behavior based on the scroll value.</em><br />
222
228
  <br />
223
229
  <b>Example:</b>
224
230
 
@@ -236,12 +242,9 @@ This parameter accepts a callback function that is triggered on every scroll eve
236
242
 
237
243
  <h2></h2>
238
244
 
239
- <details><summary><b><code>isScrolling</code></b>: <em>Callback function for scroll status.</em></summary><br /><ul><div>
240
- <b>Type:</b><br />
241
- ( motion: boolean ) => void<br />
242
- <br />
243
- <b>Description:</b> <em><br />
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 />
245
+ <details><summary><b><code>isScrolling</code></b></summary><br /><ul><div>
246
+ <b>Description:</b><em><br />
247
+ 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 />
245
248
  <br />
246
249
  <b>Example:</b>
247
250
 
@@ -260,23 +263,28 @@ This parameter accepts a callback function that is triggered whenever the scroll
260
263
 
261
264
  <h2></h2>
262
265
 
263
- ##### **VISUAL SETTINGS**:
266
+ ###### **— VISUAL SETTINGS —**
264
267
 
265
- <details><summary><b><code>size</code> REQUIRED</b>: <em>[width, height] dimension of <b>MorphScroll</b>.</em></summary><br /><ul><div>
266
- <b>Type:</b><br />
267
- number | number[] | "auto"<br />
268
- <br />
269
- <b>Description:</b> <em><br />
270
- This parameter sets the width and height of the <code>MorphScroll</code>.<br />
268
+ <details><summary><b><code>size</code></b> REQUIRED</summary><br /><ul><div>
269
+ <b>Usage:</b><br />
270
+
271
+ ```tsx
272
+ size: 100; // or [100, 70] | "auto"
273
+ ```
274
+
275
+ <b>Description:</b><em><br />
276
+ sets the width and height of the <code>MorphScroll</code>.<br />
271
277
  <br />
272
- <mark>number</mark> - Sets a fixed size in pixels. It can be 1 number if you want to set the same width and height, or an array of 2 numbers.<br />
278
+ <code><b>number</b></code>:<br />
279
+ sets a fixed size in pixels. It can be 1 number if you want to set the same width and height, or an array of 2 numbers.<br />
273
280
  <br />
274
- <mark>"auto"</mark> - Adds the <code>ResizeTracker</code> component to measure the width and height of the area where <code>MorphScroll</code> is added. The dimensions will automatically adjust when the container changes.</em><br />
281
+ <code><b>"auto"</b></code>:<br />
282
+ adds the <code>ResizeTracker</code> component to measure the width and height of the area where <code>MorphScroll</code> is added. The dimensions will automatically adjust when the container changes.</em><br />
275
283
  <br />
276
284
  <b>Example:</b>
277
285
 
278
286
  ```tsx
279
- <MorphScroll {...props} size={[100, 400]}>
287
+ <MorphScroll {...props} size={100}>
280
288
  {children}
281
289
  </MorphScroll>
282
290
  ```
@@ -287,42 +295,36 @@ This parameter sets the width and height of the <code>MorphScroll</code>.<br />
287
295
 
288
296
  <h2></h2>
289
297
 
290
- <details><summary><b><code>objectsSize</code></b>: <em>[width, height] dimension of cells for each object.</em></summary><br /><ul><div>
291
- <b>Type:</b><br />
292
- number | "size" | "firstChild" | "none"<br />
293
- | (number | "size" | "firstChild" | "none")[]<br />
294
- <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 />
297
- <br />
298
- <b>Description:</b> <em><br />
299
- This parameter defines the [width, height] of cells for each of your objects.<br />
298
+ <details><summary><b><code>objectsSize</code></b></summary><br /><ul><div>
299
+ <b>Usage:</b><br />
300
+
301
+ ```tsx
302
+ objectsSize: 100; // or [100, 70] | "size" | "firstChild" | "none"
303
+ ```
304
+
305
+ <b>Description:</b><em><br />
306
+ defines the <b>[width, height]</b> of cells for each of your objects.<br />
300
307
  <br />
301
- <mark>number</mark> - Sets a fixed size for your custom objects.<br />
308
+ <code>number</code>:<br />
309
+ sets a fixed size for your custom objects.<br />
302
310
  <br />
303
- <mark>"size"</mark> - The dimensions will be taken from <code>size</code>.<br />
311
+ <code><b>"size"</b></code>:<br />
312
+ the dimensions will be taken from <code>size</code>.<br />
304
313
  <br />
305
- <mark>"firstChild"</mark> - Creates a <code>ResizeTracker</code> wrapper for the first child of your list. This wrapper will calculate the size of the first child, and these dimensions will be applied to all cells in the list.<br />
314
+ <code><b>"firstChild"</b></code>:<br />
315
+ creates a <code>ResizeTracker</code> wrapper for the first child of your list. This wrapper will calculate the size of the first child, and these dimensions will be applied to all cells in the list.<br />
306
316
  This can be useful if you want to change the size of objects in your list dynamically, e.g., when reducing the size of the user's screen.<br />
307
317
  <br />
308
- <mark>"none"</mark> - Cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects.<br />
309
- <br />
310
- <mark>undefined</mark> - If no value is provided, the default behavior is partially inferred from the <code>size</code> prop:
311
- <ul>
312
- <li>When <code>direction="x"</code>, the height from <code>size</code> will be used, behaving as if you had passed <code>objectsSize=["size", "none"]</code>.</li>
313
- <li>When <code>direction="y"</code>, the width from <code>size</code> will be used, behaving as if you had passed <code>objectsSize=["none", "size"]</code>.</li>
314
- </ul>
318
+ <code><b>"none"</b></code>:<br />
319
+ cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects.<br />
315
320
  <br />
316
321
  ✦ Note:<br />
317
- <ul>
318
- <li>All types can be used as 1 value, or an array of 2 values.</li>
319
- <li><mark>"none"</mark> is not compatible with <code>render</code>.</li>
320
- </ul></em><br />
321
- <br />
322
+ <b>"none"</b> is not compatible with <code>render</code>.<br />
323
+ </em><br />
322
324
  <b>Example:</b>
323
325
 
324
326
  ```tsx
325
- <MorphScroll {...props} objectsSize={[80, 80]}>
327
+ <MorphScroll {...props} objectsSize={[70, 100]}>
326
328
  {children}
327
329
  </MorphScroll>
328
330
  ```
@@ -333,23 +335,20 @@ This can be useful if you want to change the size of objects in your list dynami
333
335
 
334
336
  <h2></h2>
335
337
 
336
- <details><summary><b><code>crossCount</code></b>: <em>Number of cells in each direction.</em></summary><br /><ul><div>
337
- <b>Type:</b><br />
338
- number<br />
339
- <br />
340
- <b>Description:</b> <em><br />
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 />
338
+ <details><summary><b><code>crossCount</code></b></summary><br /><ul><div>
339
+ <b>Description:</b><em><br />
340
+ defines the number of <b>columns</b> or <b>rows</b>.<br />
342
341
  <br />
343
342
  ✦ Note:<br />
344
343
  <ul>
345
- <li>If you use <mark>"x"</mark> or <mark>"y"</mark> for the <code>direction</code> parameter, <code>crossCount</code> only limits the <b>maximum</b> number of columns or rows.</li>
346
- <li>If you use <mark>"hybrid"</mark> for the <code>direction</code> parameter, <code>crossCount</code> defines the <b>exact</b> number of columns or rows in dependence of the <code>elementsDirection</code>, but not exceeding the total number of passed elements.</li>
344
+ <li>If you use <b>"x"</b> or <b>"y"</b> for the <code>direction</code> parameter, <code>crossCount</code> only limits the <b>maximum</b> number of columns or rows.</li>
345
+ <li>If you use <b>"hybrid"</b> for the <code>direction</code> parameter, <code>crossCount</code> defines the <b>exact</b> number of columns or rows in dependence of the <code>elementsDirection</code>, but not exceeding the total number of passed elements.</li>
347
346
  </ul></em><br />
348
347
  <br />
349
348
  <b>Example:</b>
350
349
 
351
350
  ```tsx
352
- <MorphScroll {...props} crossCount={3}>
351
+ <MorphScroll {...props} crossCount={2}>
353
352
  {children}
354
353
  </MorphScroll>
355
354
  ```
@@ -360,16 +359,16 @@ This parameter defines the number of <b>columns</b> (<code>direction="y"</code>,
360
359
 
361
360
  <h2></h2>
362
361
 
363
- <details><summary><b><code>gap</code></b>: <em>Gap between cells.</em></summary><br /><ul><div>
364
- <b>Type:</b><br />
365
- number | number[]<br />
366
- <br />
367
- <b>Description:</b> <em><br />
368
- This parameter allows you to set spacing in pixels between list items for rows and columns.<br />
369
- <br />
370
- ✦ Note:<br />
371
- It can be 1 number or an array of 2 numbers.</em><br />
372
- <br />
362
+ <details><summary><b><code>gap</code></b></summary><br /><ul><div>
363
+ <b>Usage:</b><br />
364
+
365
+ ```tsx
366
+ gap: 10; // or [20, 10]
367
+ ```
368
+
369
+ <b>Description:</b><em><br />
370
+ allows you to set spacing in pixels between list items for rows and columns.<br />
371
+ </em><br />
373
372
  <b>Example:</b>
374
373
 
375
374
  ```tsx
@@ -384,16 +383,16 @@ It can be 1 number or an array of 2 numbers.</em><br />
384
383
 
385
384
  <h2></h2>
386
385
 
387
- <details><summary><b><code>wrapperMargin</code></b>: <em>Margin for the <b>.ms-objects-wrapper</b>.</em></summary><br /><ul><div>
388
- <b>Type:</b><br />
389
- number | number[]<br />
390
- <br />
391
- <b>Description:</b> <em><br />
392
- This parameter defines the spacing between the list items and their wrapper, effectively increasing the width or height of the scrollable area.<br />
393
- <br />
394
- ✦ Note:<br />
395
- Can be 1 number or an array of 2 or 4 numbers in pixels.</em><br />
396
- <br />
386
+ <details><summary><b><code>wrapperMargin</code></b></summary><br /><ul><div>
387
+ <b>Usage:</b><br />
388
+
389
+ ```tsx
390
+ wrapperMargin: 10; // or [v, h] | [t, r, b, l]
391
+ ```
392
+
393
+ <b>Description:</b><em><br />
394
+ defines the spacing between the list items and their wrapper, effectively increasing the width or height of the scrollable area.<br />
395
+ </em><br />
397
396
  <b>Example:</b>
398
397
 
399
398
  ```tsx
@@ -408,16 +407,33 @@ Can be 1 number or an array of 2 or 4 numbers in pixels.</em><br />
408
407
 
409
408
  <h2></h2>
410
409
 
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>
412
- <b>Type:</b><br />
413
- number | "full" | (number | "full")[]<br />
414
- <br />
415
- <b>Description:</b> <em><br />
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 />
417
- <br />
418
- Note:<br />
419
- Can be used as 1 value, or an array of 2 values.</em><br />
420
- <br />
410
+ <details><summary><b><code>wrapperMinSize</code></b></summary><br /><ul><div>
411
+ <b>Usage:</b><br />
412
+
413
+ <ul>
414
+ <li><b>Simple</b>:<br />
415
+
416
+ ```tsx
417
+ wrapperMinSize: 10; // or "full"
418
+ ```
419
+
420
+ </li>
421
+ <li><b>Advanced</b>:<br />
422
+
423
+ ```tsx
424
+ // if direction="hybrid"
425
+ wrapperMinSize: [
426
+ "full",
427
+ 10,
428
+ ] // or one value for both sides
429
+ ```
430
+
431
+ </li>
432
+ </ul>
433
+
434
+ <b>Description:</b><em><br />
435
+ 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 />
436
+ </em><br />
421
437
  <b>Example:</b>
422
438
 
423
439
  ```tsx
@@ -432,21 +448,39 @@ Can be used as 1 value, or an array of 2 values.</em><br />
432
448
 
433
449
  <h2></h2>
434
450
 
435
- <details><summary><b><code>wrapperAlign</code></b>: <em>[horizontal, vertical] aligns your content when it is smaller than the <code>size</code>.</em></summary><br /><ul><div>
436
- <b>Type:</b><br />
437
- "start" | "center" | "end"<br />
438
- | ("start" | "center" | "end")[]<br />
439
- <br />
440
- <b>Description:</b> <em><br />
441
- This parameter aligns the <b>.ms-objects-wrapper</b>, which contains all the provided elements, relative to the scroll or the <code>size</code>.<br />
442
- <br />
443
- ✦ Note:<br />
444
- Use 1 value to align one or both axes, or an array of 2 values to align both axes.</em><br />
451
+ <details><summary><b><code>wrapperAlign</code></b></summary><br /><ul><div>
452
+ <b>Usage:</b><br />
453
+
454
+ <ul>
455
+ <li><b>Simple</b>:<br />
456
+
457
+ ```tsx
458
+ wrapperAlign: "center"; // or "start" | "end"
459
+ ```
460
+
461
+ </li>
462
+ <li><b>Advanced</b>:<br />
463
+
464
+ ```tsx
465
+ wrapperAlign: [
466
+ "center",
467
+ "start",
468
+ ] // or one value for both axes
469
+ ```
470
+
471
+ </li>
472
+ </ul>
473
+
474
+ <b>Default:</b><br />
475
+ "start"<br />
445
476
  <br />
477
+ <b>Description:</b><em><br />
478
+ aligns the <b>.ms-objects-wrapper</b>, which contains all the provided elements, relative to the scroll or the <code>size</code>.<br />
479
+ </em><br />
446
480
  <b>Example:</b>
447
481
 
448
482
  ```tsx
449
- <MorphScroll {...props} wrapperAlign={["center", "center"]}>
483
+ <MorphScroll {...props} wrapperAlign="center">
450
484
  {children}
451
485
  </MorphScroll>
452
486
  ```
@@ -457,9 +491,15 @@ Use 1 value to align one or both axes, or an array of 2 values to align both axe
457
491
 
458
492
  <h2></h2>
459
493
 
460
- <details><summary><b><code>elementsAlign</code></b>: <em>Aligns the objects inside <code>MorphScroll</code>.</em></summary><br /><ul><div>
461
- <b>Type:</b><br />
462
- "start" | "center" | "end"<br />
494
+ <details><summary><b><code>elementsAlign</code></b></summary><br /><ul><div>
495
+ <b>Usage:</b><br />
496
+
497
+ ```tsx
498
+ elementsAlign: "center"; // or "start" | "end"
499
+ ```
500
+
501
+ <b>Default:</b><br />
502
+ "start"<br />
463
503
  <br />
464
504
  <b>Example:</b>
465
505
 
@@ -475,15 +515,18 @@ Use 1 value to align one or both axes, or an array of 2 values to align both axe
475
515
 
476
516
  <h2></h2>
477
517
 
478
- <details><summary><b><code>elementsDirection</code></b>: <em>Direction of the provided elements.</em></summary><br /><ul><div>
479
- <b>Type:</b><br />
480
- "row" | "column"<br />
481
- <br />
518
+ <details><summary><b><code>elementsDirection</code></b></summary><br /><ul><div>
519
+ <b>Usage:</b><br />
520
+
521
+ ```tsx
522
+ elementsDirection: "row"; // or "column"
523
+ ```
524
+
482
525
  <b>Default:</b><br />
483
526
  "row"<br />
484
527
  <br />
485
- <b>Description:</b> <em><br />
486
- This parameter changes the order of the provided elements based on the provided value.</em><br />
528
+ <b>Description:</b><em><br />
529
+ changes the order of the provided elements based on the provided value.</em><br />
487
530
  <br />
488
531
  <b>Example:</b>
489
532
 
@@ -499,23 +542,43 @@ This parameter changes the order of the provided elements based on the provided
499
542
 
500
543
  <h2></h2>
501
544
 
502
- <details><summary><b><code>edgeGradient</code></b>: <em>Gradient overlay at the edges of the scroll area.</em></summary><br /><ul><div>
503
- <b>Type:</b><br />
504
- boolean | { color?: string; size?: number }<br />
505
- <br />
506
- <b>Default:</b><br />
507
- { size: 40 }<br />
508
- <br />
509
- <b>Description:</b> <em><br />
510
- This parameter creates two edge elements responsible for darkening the edges of the scroll when it overflows.<br />
545
+ <details><summary><b><code>edgeGradient</code></b></summary><br /><ul><div>
546
+ <b>Usage:</b><br />
547
+
548
+ <ul>
549
+ <li><b>Simple</b>:<br />
550
+
551
+ ```tsx
552
+ edgeGradient: true; // or "#fff"
553
+ ```
554
+
555
+ </li>
556
+ <li><b>Advanced</b>:<br />
557
+
558
+ ```tsx
559
+ edgeGradient: {
560
+ color: "#fff",
561
+ size: 60, // default 40px
562
+ }
563
+ ```
564
+
565
+ </li>
566
+ </ul>
567
+
568
+ <b>Description:</b><em><br />
569
+ parameter creates several edge elements responsible for darkening the edges of the scroll when it overflows.<br />
511
570
  <br />
512
- <code>color</code>:<br />
513
- The property accepts any valid color format.
571
+ <code><b>color</b></code>:<br />
572
+ property accepts any valid color format.
514
573
  If you provide it, the library will generate a gradient transitioning from the custom color to transparent.
515
- If you provide just <mark>true</mark>, the edge elements will have no color, allowing for custom styling via CSS classes.<br />
574
+ If you provide just <b>true</b>, the edge elements will have no color, allowing for custom styling via CSS class <code>.ms-edge</code>.<br />
516
575
  <br />
517
- <code>size</code>:<br />
518
- The property changes the height for horizontal and width for vertical <b>.ms-edge</b>.</em><br />
576
+ <code><b>size</b></code>:<br />
577
+ property changes the height of the edges for the horizontal and the width of the edges for the vertical.<br />
578
+ <br />
579
+ If the edge element is inactive, it gets the <code>"ms-disabled"</code> class.<br />
580
+ Also, each edge element gets the <code>--edge-visibility</code> variable in the styles with value 0 or 1.
581
+ </em><br />
519
582
  <br />
520
583
  <b>Example:</b>
521
584
 
@@ -534,55 +597,88 @@ The property changes the height for horizontal and width for vertical <b>.ms-edg
534
597
 
535
598
  <h2></h2>
536
599
 
537
- ##### **PROGRESSBAR**:
600
+ <details><summary><b><code>progressTrigger</code></b></summary><br /><ul><div>
601
+ <b>Usage:</b><br />
602
+
603
+ <ul>
604
+ <li><b>Simple</b>:<br />
605
+
606
+ ```tsx
607
+ progressTrigger: {
608
+ wheel: true,
609
+ content: true,
610
+ progressElement: true, // or <ScrollThumbComponent />
611
+ arrows: true, // or <ArrowComponent />
612
+ }
613
+ ```
614
+
615
+ </li>
616
+ <li><b>Advanced</b>:<br />
617
+
618
+ ```tsx
619
+ progressTrigger: {
620
+ wheel: {
621
+ // if direction="hybrid"
622
+ changeDirection: true,
623
+ changeDirectionKey: "someKay" // default "KeyX"
624
+ },
625
+ progressElement: [<Elem1 />, <Elem2 />, <Elem3 />],
626
+ arrows: {
627
+ element: <ArrowComponent />,
628
+ size: 60, // default 40px
629
+ contentReduce: true;
630
+ loop: true,
631
+ }
632
+ }
633
+ ```
634
+
635
+ </li>
636
+ </ul>
538
637
 
539
- <details><summary><b><code>progressTrigger</code></b>: <em>Triggers for the scroll progress.</em></summary><br /><ul><div>
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>
548
- }<br />
549
- <br />
550
638
  <b>Default:</b><br />
551
639
  { wheel: true }<br />
552
640
  <br />
553
- <b>Description:</b> <em><br />
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 />
641
+ <b>Description:</b><em><br />
642
+ this is one of the most important properties, allowing you to define how users interact with the progress bar and customize its appearance.<br />
555
643
  <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:
644
+ <code><b>wheel</b></code>:<br />
645
+ determines whether the progress bar responds to mouse wheel scrolling<br />
646
+ If you use <code>direction="hybrid"</code>, you can use:<br />
647
+
559
648
  <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>
649
+ <li><code>changeDirection</code>: allows switching the scroll direction with the mouse wheel.</li><br />
650
+ <li><code>changeDirectionKey</code>: enables switching the scroll direction by pressing a specific key.<br />
651
+ To disable this behavior, pass an empty string.<br />
652
+ <a href="https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values">more about keys</a></li>
564
653
  </ul>
565
654
  <br />
566
- <code>content</code>:<br />
567
- This parameter enables interaction by clicking and dragging anywhere within the scrollable content to move it.<br />
655
+ <code><b>content</b></code>:<br />
656
+ enables interaction by clicking and dragging anywhere within the scrollable content to move it.<br />
657
+ By using <code>content</code> drag scrolling will not work in these cases:<br />
658
+ interactive elements:<br />
659
+ <code>input</code>, <code>textarea</code>, <code>select</code>, <code>button</code>, <code>a</code><br />
660
+ elements with attribute:<br />
661
+ <code>[draggable="true"]</code>, <code>[contenteditable]</code> and custom attribute - <code>[data-ms-no-drag]</code><br />
568
662
  <br />
569
- <code>progressElement</code>:<br />
570
- This parameter determines how the scroll progress is managed.<br />
663
+ <code><b>progressElement</b></code>:<br />
664
+ determines how the scroll progress is managed<br />
571
665
  <br />
572
666
  <ul>
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 />
667
+ <li>When using <code>type="scroll"</code>, you can provide a custom scroll element. If it's not ready yet, simply set <b>true</b> instead — this will fall back to the browser’s default scrollbar.</li><br />
574
668
  <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 />
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>
669
+ <li>When using <code>type="sliderMenu"</code>, everything is the same as with <b>"slider"</b> 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>
576
670
  </ul>
577
671
  <br />
578
- <code>arrows</code>:<br />
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 />
672
+ <code><b>arrows</b></code>:<br />
673
+ allows you to add custom arrows to the progress bar<br />
580
674
  <br />
581
- ✦ Note:<br />
582
675
  <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 in browser automatically receives <code>:focus</code> when you start scrolling with the mouse wheel.</li>
585
- </ul></em><br />
676
+ <li><code>element</code>: the custom arrow element.</li><br />
677
+ <li><code>size</code>: adds a custom size to the <b>.ms-arrow-box</b>.</li><br />
678
+ <li><code>contentReduce</code>: this parameter reduces the size of the scroll content by the arrow size.</li><br />
679
+ <li><code>loop</code>: enables infinite scrolling.</li>
680
+ </ul><br />
681
+ </em><br />
586
682
  <b>Example:</b>
587
683
 
588
684
  ```tsx
@@ -601,22 +697,16 @@ This parameter allows you to add custom arrows to the progress bar. You can eith
601
697
 
602
698
  <h2></h2>
603
699
 
604
- <details><summary><b><code>progressReverse</code></b>: <em>Reverse your progress bar position.</em></summary><br /><ul><div>
605
- <b>Type:</b><br />
606
- boolean | boolean[]<br />
607
- <br />
608
- <b>Default:</b><br />
609
- false<br />
610
- <br />
611
- <b>Description:</b> <em><br />
612
- This parameter changes the position of the progress bar based on the direction property.<br />
613
- <br />
614
- <ul>
615
- <li>If <code>direction="x"</code>, the progress bar appears on the left by default and moves to the right when set to <mark>true</mark>.</li>
616
- <li>If <code>direction="y"</code>, the progress bar appears at the bottom by default and moves to the top when set to <mark>true</mark>.</li>
617
- <li>If <code>direction="hybrid"</code>, both horizontal and vertical progress bars are used with the same logic as above. And in this case, you can also pass an array of booleans to control each bar individually.</li>
618
- </ul></em><br />
619
- <br />
700
+ <details><summary><b><code>progressReverse</code></b></summary><br /><ul><div>
701
+ <b>Usage:</b><br />
702
+
703
+ ```tsx
704
+ progressReverse: true; // or [true, false] if direction="hybrid"
705
+ ```
706
+
707
+ <b>Description:</b><em><br />
708
+ this parameter changes the position of the progress bar in the opposite direction and depends on the <code>direction</code> property.<br />
709
+ </em><br />
620
710
  <b>Example:</b>
621
711
 
622
712
  ```tsx
@@ -631,17 +721,17 @@ This parameter changes the position of the progress bar based on the direction p
631
721
 
632
722
  <h2></h2>
633
723
 
634
- <details><summary><b><code>scrollBarOnHover</code></b>: <em>Progress bar hover visibility.</em></summary><br /><ul><div>
635
- <b>Type:</b><br />
636
- boolean<br />
637
- <br />
638
- <b>Default:</b><br />
639
- false<br />
640
- <br />
641
- <b>Description:</b> <em><br />
642
- This parameter controls the visibility of the progress bar regardless of the <code>type</code> value.<br />
643
- When you use it, the <b>"hover"</b> class is applied to the <b>.ms-bar</b> when the cursor is over it (or the finger touches it on touchscreens), and <b>"leave"</b> is applied when it is no longer hovered. This allows you to easily customize its appearance on interaction.</em><br />
644
- <br />
724
+ <details><summary><b><code>scrollBarOnHover</code></b></summary><br /><ul><div>
725
+ <b>Usage:</b><br />
726
+
727
+ ```tsx
728
+ scrollBarOnHover: true;
729
+ ```
730
+
731
+ <b>Description:</b><em><br />
732
+ this parameter controls the visibility of the progress bar regardless of the <code>type</code> value.<br />
733
+ When you use it, the <b>"hover"</b> class is applied to the <b>.ms-bar</b> when the cursor is over it (or the finger touches it on touchscreens), and <b>"leave"</b> is applied when it is no longer hovered. This allows you to easily customize its appearance on interaction.<br />
734
+ </em><br />
645
735
  <b>Example:</b>
646
736
 
647
737
  ```tsx
@@ -656,17 +746,19 @@ When you use it, the <b>"hover"</b> class is applied to the <b>.ms-bar</b> when
656
746
 
657
747
  <h2></h2>
658
748
 
659
- <details><summary><b><code>scrollBarEdge</code></b>: <em>Scroll bar margin at its edges.</em></summary><br /><ul><div>
660
- <b>Type:</b><br />
661
- number | number[]<br />
662
- <br />
663
- <b>Description:</b> <em><br />
664
- Defines the margin (in pixels) applied to the edges of the scroll bar, effectively reducing its size.<br />
665
- If you use <code>direction="hybrid"</code>, you can also pass an array of numbers to control each bar individually.<br />
749
+ <details><summary><b><code>scrollBarEdge</code></b></summary><br /><ul><div>
750
+ <b>Usage:</b><br />
751
+
752
+ ```tsx
753
+ scrollBarEdge: 10; // or [10, 20] for control each bar if direction="hybrid"
754
+ ```
755
+
756
+ <b>Description:</b><em><br />
757
+ defines the margin (in <b>px</b>) applied to the edges of the scroll bar, effectively reducing its size.<br />
666
758
  <br />
667
759
  ✦ Note:<br />
668
- This parameter is only used when <code>type="scroll"</code> is set.</em><br />
669
- <br />
760
+ this parameter is only used when <code>type="scroll"</code> is set.<br />
761
+ </em><br />
670
762
  <b>Example:</b>
671
763
 
672
764
  ```tsx
@@ -681,19 +773,16 @@ This parameter is only used when <code>type="scroll"</code> is set.</em><br />
681
773
 
682
774
  <h2></h2>
683
775
 
684
- <details><summary><b><code>thumbMinSize</code></b>: <em>Scroll bar thumb minimum size.</em></summary><br /><ul><div>
685
- <b>Type:</b><br />
686
- number<br />
687
- <br />
776
+ <details><summary><b><code>thumbMinSize</code></b></summary><br /><ul><div>
688
777
  <b>Default:</b><br />
689
- 30<br />
778
+ 30px<br />
690
779
  <br />
691
- <b>Description:</b> <em><br />
692
- If the scrollable content is long, this option sets the minimum size (in pixels) of the scroll bar thumb automatically.<br />
780
+ <b>Description:</b><em><br />
781
+ if the scrollable content is long, this option sets the minimum size (in <b>px</b>) of the scroll bar thumb automatically.<br />
693
782
  <br />
694
783
  ✦ Note:<br />
695
- This parameter is only used when <code>type="scroll"</code> is set.</em><br />
696
- <br />
784
+ this parameter is only used when <code>type="scroll"</code> is set.<br />
785
+ </em><br />
697
786
  <b>Example:</b>
698
787
 
699
788
  ```tsx
@@ -708,41 +797,59 @@ This parameter is only used when <code>type="scroll"</code> is set.</em><br />
708
797
 
709
798
  <h2></h2>
710
799
 
711
- ##### **OPTIMIZATIONS**:
800
+ ###### **— OPTIMIZATIONS —**
712
801
 
713
- <details><summary><b><code>render</code></b>: <em>Rendering strategy for performance optimization.</em></summary><br /><ul><div>
714
- <b>Type:</b><br />
715
- {<br />
802
+ <details><summary><b><code>render</code></b></summary><br /><ul><div>
803
+ <b>Usage:</b><br />
716
804
  <ul>
717
- type: "lazy" | "virtual";<br />
718
- rootMargin?: number | number[];<br />
719
- stopLoadOnScroll?: boolean;<br />
805
+ <li><b>Simple</b>:<br />
806
+
807
+ ```tsx
808
+ render: "lazy"; // or "virtual"
809
+ ```
810
+
811
+ </li>
812
+ <li><b>Advanced</b>:<br />
813
+
814
+ ```tsx
815
+ render: {
816
+ type: "lazy", // or "virtual" (required)
817
+ rootMargin: 100, // or [v, h] | [t, r, b, l]
818
+ stopLoadOnScroll: true,
819
+ trackVisibility: true
820
+ }
821
+ ```
822
+
823
+ </li>
720
824
  </ul>
721
- }<br />
722
- <br />
723
- <b>Description:</b> <em><br />
724
- This parameter adds a gradual rendering of the content as it enters the viewport.<br />
825
+
826
+ <b>Description:</b><em><br />
827
+ this parameter adds a gradual rendering of the content as it enters the viewport.<br />
725
828
  When used, a container is created for each scrollable object, and its absolute positioning is calculated based on scroll position and area dimensions.<br />
726
829
  <br />
727
- <code>type</code>:<br />
830
+ <code><b>type</b></code>:
831
+
728
832
  <ul>
729
- <li>With <mark>"lazy"</mark>, content is not deleted when it leaves the viewport.</li>
730
- <li>With <mark>"virtual"</mark>, content is deleted when it leaves the viewport.</li>
833
+ <li><b>"lazy"</b> - render once when visible.</li>
834
+ <li><b>"virtual"</b> - render only when visible.</li>
731
835
  </ul>
732
836
  <br />
733
- <code>rootMargin</code>:<br />
734
- This property controls the threshold for loading content. It can be a single number or an array of 2 <b>[ top-bottom, left-right ]</b> or 4 <b>[ top, right, bottom, left ]</b> numbers. It is the distance for loading from the root element ( <b>.ms-element</b> ) in pixels.<br />
837
+ <code><b>rootMargin</b></code>:<br />
838
+ controls the threshold for loading content. It is the distance for loading from the root element (<b>.ms-element</b>) in px.<br />
735
839
  <br />
736
- <code>stopLoadOnScroll</code>:<br />
737
- This property controls whether to stop loading content when scrolling.<br />
840
+ <code><b>stopLoadOnScroll</b></code>:<br />
841
+ controls whether to stop loading content when scrolling.<br />
738
842
  <br />
739
- ✦ Note:<br />
740
- <code>render</code> is not compatible with <code>objectsSize: "none"</code>.</em><br />
843
+ <code><b>trackVisibility</b></code>:<br />
844
+ sets the <code>--content-visibility</code> variable for list item wrapper styles, which is very useful for styling such as <code>opacity: var(--content-visibility);</code>.<br />
741
845
  <br />
846
+ ✦ Note:<br />
847
+ <code>render</code> is not compatible with <code>objectsSize: "none"</code>.<br />
848
+ </em><br />
742
849
  <b>Example:</b>
743
850
 
744
851
  ```tsx
745
- <MorphScroll {...props} render={{ type: "virtual" }}>
852
+ <MorphScroll {...props} render="virtual">
746
853
  {children}
747
854
  </MorphScroll>
748
855
  ```
@@ -753,46 +860,58 @@ This property controls whether to stop loading content when scrolling.<br />
753
860
 
754
861
  <h2></h2>
755
862
 
756
- <details><summary><b><code>emptyElements</code></b>: <em>Handling of empty scroll elements.</em></summary><br /><ul><div>
757
- <b>Type:</b><br />
758
- {<br />
863
+ <details><summary><b><code>emptyElements</code></b></summary><br /><ul><div>
864
+ <b>Usage:</b><br />
759
865
  <ul>
760
- mode: "clear" | "fallback" | { fallback: React.ReactNode };<br />
761
- clickTrigger?: { selector: string; delay?: number };<br />
866
+ <li><b>Simple</b>:<br />
867
+
868
+ ```tsx
869
+ emptyElements: "clear"; // or "fallback" | <FallbackComponent />
870
+ ```
871
+
872
+ </li>
873
+ <li><b>Advanced</b>:<br />
874
+
875
+ ```tsx
876
+ emptyElements: {
877
+ mode: "clear", // or "fallback" | <FallbackComponent /> (required)
878
+ clickTrigger: ".btn-class", // or { selector: ".btn-class"; delay: 100 };
879
+ }
880
+ ```
881
+
882
+ </li>
762
883
  </ul>
763
- }<br />
764
- <br />
765
- <b>Description:</b> <em><br />
766
- This option will allow you to delete or replace empty list items during the first rendering, or to start this process by clicking.<br />
884
+
885
+ <b>Description:</b><em><br />
886
+ this option allows you to remove or replace empty list items during the initial render, or trigger this process via a click action<br />
767
887
  <br />
768
- <code>mode</code>:<br />
888
+ <code><b>mode</b></code>:<br />
889
+
769
890
  <ul>
770
- <li><mark>"clear"</mark> – automatically removes empty elements.</li>
771
- <li><mark>"fallback"</mark> – replaces empty elements with the value from the <code>fallback</code> props.</li>
772
- <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>
891
+ <li><b>"clear"</b> – automatically removes empty elements.</li>
892
+ <li><b>"fallback"</b> – replaces empty elements with the value from the <code>fallback</code> props.</li>
893
+ <li><b>{ fallback: React.ReactNode }</b> – allows you to override the default <code>fallback</code> content for this instance.</li>
773
894
  </ul>
774
895
  <br />
775
- <code>clickTrigger</code>:<br />
776
- 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 />
896
+ <code><b>clickTrigger</b></code>:<br />
897
+ use this option if removal should be triggered by a click action.<br />
898
+ <ul>
899
+ <li><b>"selector"</b> – CSS selector that triggers the removal.</li>
900
+ <li><b>"delay"</b> – delay before removal ( in <b>ms</b> ).</li>
901
+ </ul>
777
902
  <br />
778
903
  ✦ Note:<br />
779
904
  <ul>
780
905
  <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>
781
906
  <li>If you use <code>clickTrigger</code>:<br />
782
907
  - consider increasing <code>delay</code>, since the cleanup may run before removal.<br />
783
- - 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>
784
- </ul></em>
785
- <br />
908
+ - 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>
909
+ </ul>
910
+ </em><br />
786
911
  <b>Example:</b>
787
912
 
788
913
  ```tsx
789
- <MorphScroll
790
- {...props}
791
- emptyElements={{
792
- mode: "clear",
793
- clickTrigger: { selector: ".close-button" },
794
- }}
795
- >
914
+ <MorphScroll {...props} emptyElements="clear">
796
915
  {children}
797
916
  </MorphScroll>
798
917
  ```
@@ -803,15 +922,18 @@ In case if elements are removed via a click action, use this option. It accepts
803
922
 
804
923
  <h2></h2>
805
924
 
806
- <details><summary><b><code>suspending</code></b>: <em>Adds React Suspense.</em></summary><br /><ul><div>
807
- <b>Type:</b><br />
808
- boolean<br />
809
- <br />
925
+ <details><summary><b><code>suspending</code></b></summary><br /><ul><div>
926
+ <b>Usage:</b><br />
927
+
928
+ ```tsx
929
+ suspending: true;
930
+ ```
931
+
810
932
  <b>Default:</b><br />
811
933
  false<br />
812
934
  <br />
813
- <b>Description:</b> <em><br />
814
- This parameter adds React Suspense to the MorphScroll component for asynchronous rendering.</em><br />
935
+ <b>Description:</b><em><br />
936
+ adds React Suspense to the MorphScroll component for async rendering.</em><br />
815
937
  <br />
816
938
  <b>Example:</b>
817
939
 
@@ -825,19 +947,18 @@ This parameter adds React Suspense to the MorphScroll component for asynchronous
825
947
 
826
948
  <h2></h2>
827
949
 
828
- <details><summary><b><code>fallback</code></b>: <em>Fallback element.</em></summary><br /><ul><div>
829
- <b>Type:</b><br />
830
- React.ReactNode<br />
950
+ <details><summary><b><code>fallback</code></b></summary><br /><ul><div>
951
+ <b>Description:</b><em><br />
952
+ sets the fallback element to display during loading or placeholder.<br />
831
953
  <br />
832
- <b>Description:</b> <em><br />
833
- This parameter sets the fallback element to display during loading or placeholder.<br />
834
954
  It will be used when:
955
+
835
956
  <ul>
836
- <li><code>suspending</code> is set to <mark>true</mark>.</li>
837
- <li><code>render.stopLoadOnScroll</code> is set to <mark>true</mark>.</li>
838
- <li><code>emptyElements.mode</code> is set to <mark>"fallback"</mark>.</li>
839
- </ul></em><br />
840
- <br />
957
+ <li><code>suspending</code> is set to <b>true</b>.</li>
958
+ <li><code>render.stopLoadOnScroll</code> is set to <b>true</b>.</li>
959
+ <li><code>emptyElements.mode</code> is set to <b>"fallback"</b>.</li>
960
+ </ul>
961
+ </em><br />
841
962
  <b>Example:</b>
842
963
 
843
964
  ```tsx
@@ -849,24 +970,20 @@ It will be used when:
849
970
  </div></ul></details>
850
971
 
851
972
  </div></ul>
973
+ </details>
852
974
 
853
975
  <h2></h2>
854
976
 
855
- #### ResizeTracker
856
-
857
- `ResizeTracker` is a React component that monitors changes to an element’s size. It provides updated dimensions via a render-prop function whenever the observed element is resized.
977
+ <details><summary><b>ResizeTracker</b>: <em>component that monitors changes to an element’s size</em></summary>
858
978
 
859
979
  - #### Props:
860
980
 
861
981
  <ul><div>
862
982
 
863
- <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
864
- <b>Type:</b><br />
865
- string<br />
866
- <br />
867
- <b>Description:</b> <em><br />
868
- This parameter allows you to add additional classes to the component.</em><br />
869
- <br />
983
+ <details><summary><b><code>className</code></b></summary><br /><ul><div>
984
+ <b>Description:</b><em><br />
985
+ allows to add additional classes to the component.<br />
986
+ </em><br />
870
987
  <b>Example:</b>
871
988
 
872
989
  ```tsx
@@ -877,13 +994,10 @@ This parameter allows you to add additional classes to the component.</em><br />
877
994
 
878
995
  <h2></h2>
879
996
 
880
- <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
881
- <b>Type:</b><br />
882
- React.ReactNode<br />
883
- <br />
884
- <b>Description:</b> <em><br />
885
- This parameter allows you to add custom content to the component.</em><br />
886
- <br />
997
+ <details><summary><b><code>children</code></b></summary><br /><ul><div>
998
+ <b>Description:</b><em><br />
999
+ allows to add custom content to the component.<br />
1000
+ </em><br />
887
1001
  <b>Example:</b>
888
1002
 
889
1003
  ```tsx
@@ -894,10 +1008,10 @@ This parameter allows you to add custom content to the component.</em><br />
894
1008
 
895
1009
  <h2></h2>
896
1010
 
897
- <details><summary><b><code>style</code></b>: <em>Applies inline styles to the container.</em></summary><br /><ul><div>
898
- <b>Type:</b><br />
899
- React.CSSProperties<br />
900
- <br />
1011
+ <details><summary><b><code>style</code></b></summary><br /><ul><div>
1012
+ <b>Description:</b><em><br />
1013
+ allows to add custom inline styles.<br />
1014
+ </em><br />
901
1015
  <b>Example:</b>
902
1016
 
903
1017
  ```tsx
@@ -908,21 +1022,27 @@ React.CSSProperties<br />
908
1022
 
909
1023
  <h2></h2>
910
1024
 
911
- <details><summary><b><code>measure</code></b>: <em>Defines the measurement strategy.</em></summary><br /><ul><div>
912
- <b>Type:</b><br />
913
- "inner" | "outer" | "all"<br />
914
- <br />
1025
+ <details><summary><b><code>measure</code></b></summary><br /><ul><div>
1026
+ <b>Usage:</b><br />
1027
+
1028
+ ```tsx
1029
+ measure: "outer"; // or "inner" | "all"
1030
+ ```
1031
+
915
1032
  <b>Default:</b><br />
916
1033
  "inner"<br />
917
1034
  <br />
918
- <b>Description:</b><br />
919
- <em>This prop determines what is being measured by automatically applying inline styles that affect width and height.<br />
1035
+ <b>Description:</b><em><br />
1036
+ determines what is being measured by automatically applying inline styles that affect width and height.<br />
920
1037
  <br />
921
- <ul>
922
- <li><mark>"inner"</mark> sets <code>width: "max-content"</code> and <code>height: "max-content"</code>, measuring the size of child elements.</li>
923
- <li><mark>"outer"</mark> measures the parent element by setting <code>minWidth: "100%"</code> and <code>minHeight: "100%"</code>.</li>
924
- <li><mark>"all"</mark> value combines the styles of both <code>"inner"</code> and <code>"outer"</code>, allowing measurement of both the parent and child elements.</li>
925
- </ul>
1038
+ <code><b>"inner"</b></code>:<br />
1039
+ sets <code>width: "max-content"</code> and <code>height: "max-content"</code>, measuring the size of child elements.<br />
1040
+ <br />
1041
+ <code><b>"outer"</b></code>:<br />
1042
+ measures the parent element by setting <code>minWidth: "100%"</code> and <code>minHeight: "100%"</code>.<br />
1043
+ <br />
1044
+ <code><b>"all"</b></code>:<br />
1045
+ value combines the styles of both <code>"inner"</code> and <code>"outer"</code>, allowing measurement of both the parent and child elements.<br />
926
1046
  <br />
927
1047
  ✦ Note: <br />
928
1048
  Be cautious when overriding styles via the <code>style</code> prop, as it may interfere with the styles applied by <code>measure</code>, leading to unexpected behavior.</em><br />
@@ -937,14 +1057,11 @@ Be cautious when overriding styles via the <code>style</code> prop, as it may in
937
1057
 
938
1058
  <h2></h2>
939
1059
 
940
- <details><summary><b><code>onResize</code></b>: <em>Callback triggered on size changes.</em></summary><br /><ul><div>
941
- <b>Type:</b><br />
942
- (rect: Partial<DOMRectReadOnly>) => void<br />
943
- <br />
944
- <b>Description:</b><br />
945
- <em>A callback function that is triggered whenever the observed element's dimensions change.<br />
946
- The function receives an object containing the updated size properties.</em><br />
947
- <br />
1060
+ <details><summary><b><code>onResize</code></b></summary><br /><ul><div>
1061
+ <b>Description:</b><em><br />
1062
+ callback function that is triggered whenever the observed element's dimensions change.<br />
1063
+ The function receives an object of type <b>Partial<DOMRectReadOnly></b> that containing updated size properties.<br />
1064
+ </em><br />
948
1065
  <b>Example:</b>
949
1066
 
950
1067
  ```tsx
@@ -963,27 +1080,24 @@ The function receives an object containing the updated size properties.</em><br
963
1080
 
964
1081
  </div></ul>
965
1082
 
966
- - #### Link:
1083
+ - #### Links:
967
1084
 
968
1085
  [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
969
1086
 
970
- <h2></h2>
1087
+ </details>
971
1088
 
972
- #### ♦ IntersectionTracker
1089
+ <h2></h2>
973
1090
 
974
- `IntersectionTracker` is a React component for tracking the intersection of an element with the viewport.
1091
+ <details><summary><b>IntersectionTracker</b>: <em>component for tracking the intersection of an element with the viewport</em></summary>
975
1092
 
976
1093
  - #### Props:
977
1094
 
978
1095
  <ul><div>
979
1096
 
980
- <details><summary><b><code>className</code></b>: <em>Additional classes.</em></summary><br /><ul><div>
981
- <b>Type:</b><br />
982
- string<br />
983
- <br />
984
- <b>Description:</b> <em><br />
985
- This parameter allows you to add additional classes to the component.</em><br />
986
- <br />
1097
+ <details><summary><b><code>className</code></b></summary><br /><ul><div>
1098
+ <b>Description:</b><em><br />
1099
+ allows to add additional classes to the component.<br />
1100
+ </em><br />
987
1101
  <b>Example:</b>
988
1102
 
989
1103
  ```tsx
@@ -994,10 +1108,10 @@ This parameter allows you to add additional classes to the component.</em><br />
994
1108
 
995
1109
  <h2></h2>
996
1110
 
997
- <details><summary><b><code>children</code></b>: <em>Custom user content.</em></summary><br /><ul><div>
998
- <b>Type:</b><br />
999
- React.ReactNode<br />
1000
- <br />
1111
+ <details><summary><b><code>children</code></b></summary><br /><ul><div>
1112
+ <b>Description:</b><em><br />
1113
+ allows to add custom content to the component.<br />
1114
+ </em><br />
1001
1115
  <b>Example:</b>
1002
1116
 
1003
1117
  ```tsx
@@ -1008,10 +1122,10 @@ React.ReactNode<br />
1008
1122
 
1009
1123
  <h2></h2>
1010
1124
 
1011
- <details><summary><b><code>style</code></b>: <em>Applies inline styles to the container.</em></summary><br /><ul><div>
1012
- <b>Type:</b><br />
1013
- React.CSSProperties<br />
1014
- <br />
1125
+ <details><summary><b><code>style</code></b></summary><br /><ul><div>
1126
+ <b>Description:</b><em><br />
1127
+ allows to add custom inline styles.<br />
1128
+ </em><br />
1015
1129
  <b>Example:</b>
1016
1130
 
1017
1131
  ```tsx
@@ -1024,17 +1138,14 @@ React.CSSProperties<br />
1024
1138
 
1025
1139
  <h2></h2>
1026
1140
 
1027
- <details><summary><b><code>root</code></b>: <em>Defines the observation area.</em></summary><br /><ul><div>
1028
- <b>Type:</b><br />
1029
- Element | null<br />
1030
- <br />
1141
+ <details><summary><b><code>root</code></b></summary><br /><ul><div>
1031
1142
  <b>Default:</b><br />
1032
- null (window)<br />
1033
- <br />
1034
- <b>Description:</b> <em><br />
1035
- Specifies the element that serves as the bounding box for the intersection observation.
1036
- If provided, it must be an ancestor of the observed element.</em><br />
1143
+ null (browser window)<br />
1037
1144
  <br />
1145
+ <b>Description:</b><em><br />
1146
+ specifies the element that serves as the bounding box for the intersection observation.
1147
+ If provided, it must be an ancestor of the observed element.<br />
1148
+ </em><br />
1038
1149
  <b>Example:</b>
1039
1150
 
1040
1151
  ```tsx
@@ -1047,16 +1158,16 @@ If provided, it must be an ancestor of the observed element.</em><br />
1047
1158
 
1048
1159
  <h2></h2>
1049
1160
 
1050
- <details><summary><b><code>rootMargin</code></b>: <em>Sets the margin around the root element.</em></summary><br /><ul><div>
1051
- <b>Type:</b><br />
1052
- number | number[]<br />
1053
- <br />
1054
- <b>Description:</b> <em><br />
1055
- Defines an offset around the root element, expanding or shrinking the observed area.<br />
1056
- <br />
1057
- ✦ Note:<br />
1058
- It can be a single number or an array of 2 <b>[ top-bottom, left-right ]</b> or 4 <b>[ top, right, bottom, left ]</b> numbers.</em><br />
1059
- <br />
1161
+ <details><summary><b><code>rootMargin</code></b></summary><br /><ul><div>
1162
+ <b>Usage:</b><br />
1163
+
1164
+ ```tsx
1165
+ rootMargin: 10; // or [v, h] | [t, r, b, l]
1166
+ ```
1167
+
1168
+ <b>Description:</b><em><br />
1169
+ defines an offset around the root element, expanding or shrinking the observed area.<br />
1170
+ </em><br />
1060
1171
  <b>Example:</b>
1061
1172
 
1062
1173
  ```tsx
@@ -1067,17 +1178,21 @@ It can be a single number or an array of 2 <b>[ top-bottom, left-right ]</b> or
1067
1178
 
1068
1179
  <h2></h2>
1069
1180
 
1070
- <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>
1071
- <b>Type:</b><br />
1072
- number | number[]<br />
1073
- <br />
1181
+ <details><summary><b><code>threshold</code></b></summary><br /><ul><div>
1182
+ <b>Usage:</b><br />
1183
+
1184
+ ```tsx
1185
+ threshold: 0.5; // or [0, 0.5, 1]
1186
+ ```
1187
+
1074
1188
  <b>Default:</b><br />
1075
1189
  0<br />
1076
1190
  <br />
1077
- <b>Description:</b> <em><br />
1078
- Specifies at what percentage of the observed element’s visibility the callback should be executed.<br />
1191
+ <b>Description:</b><em><br />
1192
+ specifies at what percentage of the observed element’s visibility the callback <code>onIntersection</code> should be executed.<br />
1079
1193
  <br />
1080
1194
  ✦ Note:<br />
1195
+
1081
1196
  <ul>
1082
1197
  <li>A value of <code>0</code> means the callback fires when any part of the element appears, while <code>1</code> means the element must be fully visible.</li>
1083
1198
  <li>An array (e.g., <code>[0, 0.5, 1]</code>) triggers the callback multiple times at different visibility levels.</li>
@@ -1093,15 +1208,18 @@ Specifies at what percentage of the observed element’s visibility the callback
1093
1208
 
1094
1209
  <h2></h2>
1095
1210
 
1096
- <details><summary><b><code>visibleContent</code></b>: <em>Makes all elements always visible.</em></summary><br /><ul><div>
1097
- <b>Type:</b><br />
1098
- boolean<br />
1099
- <br />
1211
+ <details><summary><b><code>visibleContent</code></b></summary><br /><ul><div>
1212
+ <b>Usage:</b><br />
1213
+
1214
+ ```tsx
1215
+ visibleContent: true;
1216
+ ```
1217
+
1100
1218
  <b>Default:</b><br />
1101
1219
  false<br />
1102
1220
  <br />
1103
- <b>Description:</b> <em><br />
1104
- If set to <mark>true</mark>, the tracked elements will always be visible, regardless of their actual intersection status.<br />
1221
+ <b>Description:</b><em><br />
1222
+ if set to <b>true</b>, the tracked elements will always be visible, regardless of their actual intersection status.<br />
1105
1223
  This is useful for testing purposes or when using the <code>onIntersection</code> callback, ensuring that it reliably triggers whenever the element enters the viewport, even if all elements are already visible.</em><br />
1106
1224
  <br />
1107
1225
  <b>Example:</b>
@@ -1114,22 +1232,19 @@ This is useful for testing purposes or when using the <code>onIntersection</code
1114
1232
 
1115
1233
  <h2></h2>
1116
1234
 
1117
- <details><summary><b><code>onIntersection</code></b>: <em>Callback function triggered when the element becomes visible.</em></summary><br /><ul><div>
1118
- <b>Type:</b><br />
1119
- (entry: IntersectionObserverEntry) => void<br />
1120
- <br />
1121
- <b>Description:</b> <em><br />
1122
- 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 />
1235
+ <details><summary><b><code>onIntersection</code></b></summary><br /><ul><div>
1236
+ <b>Description:</b><em><br />
1237
+ 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 />
1123
1238
  <br />
1124
1239
  ✦ Note:<br />
1125
- The <code>IntersectionObserverEntry</code> object provides details about the intersection state, including:<br />
1240
+ <code>entry</code> is an object of type <b>IntersectionObserverEntry</b> that provides details about the intersection state, including:<br />
1126
1241
  <ul>
1127
- <li><code>boundingClientRect</code>: The bounding rectangle of the element relative to the viewport.</li>
1128
- <li><code>intersectionRatio</code>: The percentage of the element that is visible in the viewport.</li>
1129
- <li><code>intersectionRect</code>: The intersection rectangle between the element and the viewport.</li>
1130
- <li><code>rootBounds</code>: The bounding rectangle of the root element relative to the viewport.</li>
1131
- <li><code>target</code>: The observed element.</li>
1132
- <li><code>time</code>: The timestamp when the intersection state changed.</li>
1242
+ <li><code>boundingClientRect</code>: bounding rectangle of the element relative to the viewport.</li>
1243
+ <li><code>intersectionRatio</code>: percentage of the element that is visible in the viewport.</li>
1244
+ <li><code>intersectionRect</code>: intersection rectangle between the element and the viewport.</li>
1245
+ <li><code>rootBounds</code>: bounding rectangle of the root element relative to the viewport.</li>
1246
+ <li><code>target</code>: observed element.</li>
1247
+ <li><code>time</code>: timestamp when the intersection state changed.</li>
1133
1248
  </ul></em>
1134
1249
  <br />
1135
1250
  <b>Example:</b>
@@ -1150,10 +1265,12 @@ The <code>IntersectionObserverEntry</code> object provides details about the int
1150
1265
 
1151
1266
  </div></ul>
1152
1267
 
1153
- - #### Link:
1268
+ - #### Links:
1154
1269
 
1155
1270
  [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
1156
1271
 
1272
+ </details>
1273
+
1157
1274
  </div></ul>
1158
1275
 
1159
1276
  <h2></h2>