morphing-scroll 1.5.20 → 1.5.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +1036 -999
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -35,728 +35,757 @@ npm install morphing-scroll
35
35
 
36
36
  - ### Props:
37
37
 
38
+ <div>
39
+
38
40
  #### GENERAL SETTINGS:
39
41
 
40
- <details>
41
- <summary><strong><code>className</code></strong>: <em>Additional classes for the component.</em></summary><br />
42
- <ul>
43
- <strong>Type:</strong> string<br />
44
- <br />
45
- <strong>Description:</strong> <em><br />
46
- This parameter allows you to apply custom CSS classes to the <code>MorphScroll</code> component, enabling further customization and styling to fit your design needs.</em><br />
47
- <br />
48
- <strong>Example:</strong>
49
-
50
- ```tsx
51
- <MorphScroll
52
- className="your-class"
53
- // another props
54
- >
55
- {children}
56
- </MorphScroll>
57
- ```
58
-
59
- </ul>
60
- </details>&nbsp;
61
- <h2></h2>&nbsp;
62
- <details>
63
- <summary><strong><code>children</code></strong>: <em>Custom user content.</em></summary><br />
64
- <ul>
65
- <strong>Type:</strong> React.ReactNode<br />
66
- <br />
67
- <strong>Description:</strong> <em><br />
68
- This is where you can pass your list elements.<br />
69
- 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 />
70
- Additionally, <code>MorphScroll</code> handles a passed <code>null</code> value the same way as <code>undefined</code>, rendering nothing in both cases.</em><br />
71
- <br />
72
- <strong>Example:</strong>
73
-
74
- ```tsx
75
- <MorphScroll
76
- // props
77
- >
78
- {children}
79
- </MorphScroll>
80
- ```
81
-
82
- </ul>
83
- </details>
84
-
85
- <h2></h2>
42
+ <details>
43
+ <summary><strong><code>className</code></strong>: <em>Additional classes for the component.</em></summary><br />
44
+ <ul>
45
+ <strong>Type:</strong> string<br />
46
+ <br />
47
+ <strong>Description:</strong> <em><br />
48
+ This parameter allows you to apply custom CSS classes to the <code>MorphScroll</code> component, enabling further customization and styling to fit your design needs.</em><br />
49
+ <br />
50
+ <strong>Example:</strong>
51
+
52
+ ```tsx
53
+ <MorphScroll
54
+ className="your-class"
55
+ // another props
56
+ >
57
+ {children}
58
+ </MorphScroll>
59
+ ```
60
+
61
+ </ul>
62
+
63
+ </details>
64
+
65
+ <h2></h2>
66
+
67
+ <details>
68
+ <summary><strong><code>children</code></strong>: <em>Custom user content.</em></summary><br />
69
+ <ul>
70
+ <strong>Type:</strong> React.ReactNode<br />
71
+ <br />
72
+ <strong>Description:</strong> <em><br />
73
+ This is where you can pass your list elements.<br />
74
+ 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 />
75
+ Additionally, <code>MorphScroll</code> handles a passed <code>null</code> value the same way as <code>undefined</code>, rendering nothing in both cases.</em><br />
76
+ <br />
77
+ <strong>Example:</strong>
78
+
79
+ ```tsx
80
+ <MorphScroll
81
+ // props
82
+ >
83
+ {children}
84
+ </MorphScroll>
85
+ ```
86
+
87
+ </ul>
88
+
89
+ </details>
90
+
91
+ <h2></h2>
86
92
 
87
93
  #### SCROLL SETTINGS:
88
94
 
89
- <details>
90
- <summary><strong><code>type</code></strong>: <em>Type of progress element.</em></summary><br />
91
- <ul>
92
- <strong>Type:</strong> "scroll" | "slider"<br />
93
- <br />
94
- <strong>Default:</strong> "scroll"<br />
95
- <br />
96
- <strong>Description:</strong> <em><br />
97
- This parameter defines how the provided <code>progressElement</code> behaves within <code>progressTrigger</code> and how you interact with it.<br />
98
- With the default <code>type="scroll"</code>, it functions as a typical scrollbar. However, with <code>type="slider"</code>, it displays distinct elements indicating the number of full scroll steps within the list.<br />
99
- For More details, refer to <code>progressTrigger/progressElement</code>.</em><br />
100
- <br />
101
- <strong>Example:</strong>
102
-
103
- ```tsx
104
- <MorphScroll
105
- type="slider"
106
- // another props
107
- >
108
- {children}
109
- </MorphScroll>
110
- ```
111
-
112
- </ul>
113
- </details>
114
-
115
- <h2></h2>
116
-
117
- <details>
118
- <summary><strong><code>direction</code></strong>: <em>Scrolling direction.</em></summary><br />
119
- <ul>
120
- <strong>Type:</strong> "x" | "y"<br />
121
- <br />
122
- <strong>Default:</strong> "y"<br />
123
- <br />
124
- <strong>Description:</strong> <em><br />
125
- This parameter changes the scroll or slider type direction based on the provided value.<br />
126
- You can set it to horizontal or vertical to customize the component according to your needs.</em><br />
127
- <br />
128
- <strong>Example:</strong>
129
-
130
- ```tsx
131
- <MorphScroll
132
- direction="x"
133
- // another props
134
- >
135
- {children}
136
- </MorphScroll>
137
- ```
138
-
139
- </ul>
140
- </details>
141
-
142
- <h2></h2>
143
-
144
- <details>
145
- <summary><strong><code>scrollTop</code></strong>: <em>Scroll position and animation duration.</em></summary><br />
146
- <ul>
147
- <strong>Type:</strong> {<br />
148
- value: number | "end";<br />
149
- duration?: number;<br />
150
- updater?: boolean;<br />
151
- }<br />
152
- <br />
153
- <strong>Default:</strong> { value: 0; duration: 200; updater: false }<br />
154
- <br />
155
- <strong>Description:</strong> <em><br />
156
- This parameter allows you to set custom scroll values.<br />
157
- <br />
158
- The <code>value</code> property accepts numerical pixel values.<br />
159
- The <code>"end"</code> option 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.<br />
160
- <br />
161
- The <code>duration</code> property determines the animation speed for scrolling in ms.</em><br />
162
- <br />
163
- The <code>updater</code> 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 />
164
- <code>setScroll((prev) => ({ ...prev, value: 0, updater: !prev.updater }))</code></em><br />
165
- <br />
166
- <strong>Example:</strong>
167
-
168
- ```tsx
169
- <MorphScroll
170
- scrollTop={{ value: 100; duration: 100 }}
171
- // another props
172
- >
173
- {children}
174
- </MorphScroll>
175
- ```
176
-
177
- </ul>
178
- </details>
179
-
180
- <h2></h2>
181
-
182
- <details>
183
- <summary><strong><code>stopLoadOnScroll</code></strong>: <em>Stop loading when scrolling.</em></summary><br />
184
- <ul>
185
- <strong>Type:</strong> boolean<br />
186
- <br />
187
- <strong>Default:</strong> false<br />
188
- <br />
189
- <strong>Description:</strong> <em><br />
190
- This parameter helps optimize list performance during scrolling. When set to <code>true</code>, new items will not load while the list is being scrolled and will only load after scrolling stops. This can be particularly useful for lists with a large number of items.</em><br />
191
- <br />
192
- <strong>Example:</strong>
193
-
194
- ```tsx
195
- <MorphScroll
196
- stopLoadOnScroll
197
- // another props
198
- >
199
- {children}
200
- </MorphScroll>
201
- ```
202
-
203
- </ul>
204
- </details>
205
-
206
- <h2></h2>
207
-
208
- <details>
209
- <summary><strong><code>onScrollValue</code></strong>: <em>Callback for scroll value.</em></summary><br />
210
- <ul>
211
- <strong>Type:</strong> (scroll: number) => void<br />
212
- <br />
213
- <strong>Description:</strong> <em><br />
214
- This parameter accepts a callback function that is triggered on every scroll event. The callback receives the current scroll position as a number. The return value of the callback can be used to determine custom behavior based on the scroll value.</em><br />
215
- <br />
216
- <strong>Example:</strong>
217
-
218
- ```tsx
219
- <MorphScroll
220
- onScrollValue={
221
- (scroll) => {
222
- console.log("Scroll position:", scroll);
223
- return scroll > 100;
224
- },
225
- }
226
- // another props
227
- >
228
- {children}
229
- </MorphScroll>
230
- ```
95
+ <details>
96
+ <summary><strong><code>type</code></strong>: <em>Type of progress element.</em></summary><br />
97
+ <ul>
98
+ <strong>Type:</strong> "scroll" | "slider"<br />
99
+ <br />
100
+ <strong>Default:</strong> "scroll"<br />
101
+ <br />
102
+ <strong>Description:</strong> <em><br />
103
+ This parameter defines how the provided <code>progressElement</code> behaves within <code>progressTrigger</code> and how you interact with it.<br />
104
+ With the default <code>type="scroll"</code>, it functions as a typical scrollbar. However, with <code>type="slider"</code>, it displays distinct elements indicating the number of full scroll steps within the list.<br />
105
+ For More details, refer to <code>progressTrigger/progressElement</code>.</em><br />
106
+ <br />
107
+ <strong>Example:</strong>
108
+
109
+ ```tsx
110
+ <MorphScroll
111
+ type="slider"
112
+ // another props
113
+ >
114
+ {children}
115
+ </MorphScroll>
116
+ ```
231
117
 
232
- </ul>
233
- </details>
234
-
235
- <h2></h2>
236
-
237
- <details>
238
- <summary><strong><code>isScrolling</code></strong>: <em>Callback function for scroll status.</em></summary><br />
239
- <ul>
240
- <strong>Type:</strong> (motion: boolean) => void<br />
241
- <br />
242
- <strong>Description:</strong> <em><br />
243
- 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 />
244
- <br />
245
- <strong>Example:</strong>
246
-
247
- ```tsx
248
- <MorphScroll
249
- isScrolling={(motion) => {
250
- console.log(motion ? "Scrolling..." : "Scroll stopped.");
251
- }}
252
- // another props
253
- >
254
- {children}
255
- </MorphScroll>
256
- ```
118
+ </ul>
119
+
120
+ </details>
121
+
122
+ <h2></h2>
123
+
124
+ <details>
125
+ <summary><strong><code>direction</code></strong>: <em>Scrolling direction.</em></summary><br />
126
+ <ul>
127
+ <strong>Type:</strong> "x" | "y"<br />
128
+ <br />
129
+ <strong>Default:</strong> "y"<br />
130
+ <br />
131
+ <strong>Description:</strong> <em><br />
132
+ This parameter changes the scroll or slider type direction based on the provided value.<br />
133
+ You can set it to horizontal or vertical to customize the component according to your needs.</em><br />
134
+ <br />
135
+ <strong>Example:</strong>
136
+
137
+ ```tsx
138
+ <MorphScroll
139
+ direction="x"
140
+ // another props
141
+ >
142
+ {children}
143
+ </MorphScroll>
144
+ ```
145
+
146
+ </ul>
147
+
148
+ </details>
149
+
150
+ <h2></h2>
151
+
152
+ <details>
153
+ <summary><strong><code>scrollTop</code></strong>: <em>Scroll position and animation duration.</em></summary><br />
154
+ <ul>
155
+ <strong>Type:</strong> {<br />
156
+ value: number | "end";<br />
157
+ duration?: number;<br />
158
+ updater?: boolean;<br />
159
+ }<br />
160
+ <br />
161
+ <strong>Default:</strong> { value: 0; duration: 200; updater: false }<br />
162
+ <br />
163
+ <strong>Description:</strong> <em><br />
164
+ This parameter allows you to set custom scroll values.<br />
165
+ <br />
166
+ The <code>value</code> property accepts numerical pixel values.<br />
167
+ The <code>"end"</code> option 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.<br />
168
+ <br />
169
+ The <code>duration</code> property determines the animation speed for scrolling in ms.</em><br />
170
+ <br />
171
+ The <code>updater</code> 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 />
172
+ <code>setScroll((prev) => ({ ...prev, value: 0, updater: !prev.updater }))</code></em><br />
173
+ <br />
174
+ <strong>Example:</strong>
175
+
176
+ ```tsx
177
+ <MorphScroll
178
+ scrollTop={{ value: 100; duration: 100 }}
179
+ // another props
180
+ >
181
+ {children}
182
+ </MorphScroll>
183
+ ```
184
+
185
+ </ul>
186
+
187
+ </details>
188
+
189
+ <h2></h2>
190
+
191
+ <details>
192
+ <summary><strong><code>stopLoadOnScroll</code></strong>: <em>Stop loading when scrolling.</em></summary><br />
193
+ <ul>
194
+ <strong>Type:</strong> boolean<br />
195
+ <br />
196
+ <strong>Default:</strong> false<br />
197
+ <br />
198
+ <strong>Description:</strong> <em><br />
199
+ This parameter helps optimize list performance during scrolling. When set to <code>true</code>, new items will not load while the list is being scrolled and will only load after scrolling stops. This can be particularly useful for lists with a large number of items.</em><br />
200
+ <br />
201
+ <strong>Example:</strong>
202
+
203
+ ```tsx
204
+ <MorphScroll
205
+ stopLoadOnScroll
206
+ // another props
207
+ >
208
+ {children}
209
+ </MorphScroll>
210
+ ```
211
+
212
+ </ul>
213
+
214
+ </details>
215
+
216
+ <h2></h2>
217
+
218
+ <details>
219
+ <summary><strong><code>onScrollValue</code></strong>: <em>Callback for scroll value.</em></summary><br />
220
+ <ul>
221
+ <strong>Type:</strong> (scroll: number) => void<br />
222
+ <br />
223
+ <strong>Description:</strong> <em><br />
224
+ This parameter accepts a callback function that is triggered on every scroll event. The callback receives the current scroll 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
+ <br />
226
+ <strong>Example:</strong>
227
+
228
+ ```tsx
229
+ <MorphScroll
230
+ onScrollValue={
231
+ (scroll) => {
232
+ console.log("Scroll position:", scroll);
233
+ return scroll > 100;
234
+ },
235
+ }
236
+ // another props
237
+ >
238
+ {children}
239
+ </MorphScroll>
240
+ ```
241
+
242
+ </ul>
243
+
244
+ </details>
245
+
246
+ <h2></h2>
247
+
248
+ <details>
249
+ <summary><strong><code>isScrolling</code></strong>: <em>Callback function for scroll status.</em></summary><br />
250
+ <ul>
251
+ <strong>Type:</strong> (motion: boolean) => void<br />
252
+ <br />
253
+ <strong>Description:</strong> <em><br />
254
+ 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 />
255
+ <br />
256
+ <strong>Example:</strong>
257
+
258
+ ```tsx
259
+ <MorphScroll
260
+ isScrolling={(motion) => {
261
+ console.log(motion ? "Scrolling..." : "Scroll stopped.");
262
+ }}
263
+ // another props
264
+ >
265
+ {children}
266
+ </MorphScroll>
267
+ ```
268
+
269
+ </ul>
257
270
 
258
- </ul>
259
- </details>
271
+ </details>
260
272
 
261
- <h2></h2>
273
+ <h2></h2>
262
274
 
263
275
  #### VISUAL SETTINGS:
264
276
 
265
- <details>
266
- <summary><strong><code>size</code></strong>: <em>MorphScroll width and height.</em></summary><br />
267
- <ul>
268
- <strong>Type:</strong> number[]<br />
269
- <br />
270
- <strong>Description:</strong> <em><br />
271
- This parameter sets the width and height of the <code>MorphScroll</code> component as an array of two numbers. These values help define the visual container for the scrollable area.<br />
272
- <br />
273
- If this parameter is not specified, <code>MorphScroll</code> will use 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.<br />
274
- <br />
275
- ⚠ Note:<br />
277
+ <details>
278
+ <summary><strong><code>size</code></strong>: <em>MorphScroll width and height.</em></summary><br />
276
279
  <ul>
277
- <li>The values are specified following the <code>width/height</code> rule in pixels, regardless of the <code>direction</code>.</li>
278
- <li>See the <code>ResizeTracker</code> section for more details.</li>
279
- </ul></em><br />
280
- <br />
281
- <strong>Example:</strong>
282
-
283
- ```tsx
284
- <MorphScroll
285
- size={[100, 400]}
286
- // another props
287
- >
288
- {children}
289
- </MorphScroll>
290
- ```
291
-
292
- </ul>
293
- </details>
294
-
295
- <h2></h2>
296
-
297
- <details>
298
- <summary><strong><code>objectsSize</code> (required)</strong>: <em>Required: Size of cells for each object.</em></summary><br />
299
- <ul>
300
- <strong>Type:</strong> (number | "none" | "firstChild")[]<br />
301
- <br />
302
- <strong>Description:</strong> <em><br />
303
- This parameter is the only required one. It defines the size of cells for each of your objects. <code>ObjectsSize</code> use an array of values.<br />
304
- <br />
305
- If you pass <code>"none"</code>, cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects. In this case, for example, you won’t be able to use the <code>infiniteScroll</code> feature, as it requires specific cell sizes for absolute positioning.. However, this is not a drawback if you are building something like a chat or a news feed, where the content can have varying heights, and it’s better to load new content as the user approaches the end of the existing list.<br />
306
- <br />
307
- If you specify the value <code>"firstChild"</code>, a <code>ResizeTracker</code> wrapper will be created 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 />
308
- <br />
309
- ⚠ Note:<br />
310
- The numbers are specified following the <code>width/height</code> rule, regardless of the <code>direction</code>.</em><br />
311
- <br />
312
- <strong>Example:</strong>
313
-
314
- ```tsx
315
- <MorphScroll
316
- objectsSize={[40, 40]}
317
- // objectsSize={["none", "none"]}
318
- // objectsSize={["firstChild", "firstChild"]}
319
- // another props
320
- >
321
- {children}
322
- </MorphScroll>
323
- ```
324
-
325
- </ul>
326
- </details>
327
-
328
- <h2></h2>
329
-
330
- <details>
331
- <summary><strong><code>gap</code></strong>: <em>Gap between cells.</em></summary><br />
332
- <ul>
333
- <strong>Type:</strong> number[] | number<br />
334
- <br />
335
- <strong>Description:</strong> <em><br />
336
- This parameter allows you to set spacing between list items both horizontally and vertically. You can provide a single value, which will apply to both directions, or an array of two numbers to define separate spacing values.<br />
337
- <br />
338
- ⚠ Note:<br />
339
- The values are specified following the <code>horizontal/vertical</code> rule in pixels, regardless of the <code>direction</code>.</em><br />
340
- <br />
341
- <strong>Example:</strong>
342
-
343
- ```tsx
344
- <MorphScroll
345
- gap={10}
346
- // gap={[10, 10]}
347
- // another props
348
- >
349
- {children}
350
- </MorphScroll>
351
- ```
352
-
353
- </ul>
354
- </details>
355
-
356
- <h2></h2>
357
-
358
- <details>
359
- <summary><strong><code>padding</code></strong>: <em>Padding for the <code>objectsWrapper</code>.</em></summary><br />
360
- <ul>
361
- <strong>Type:</strong> number[] | number<br />
362
- <br />
363
- <strong>Description:</strong> <em><br />
364
- This parameter defines the spacing between the list items and their wrapper, effectively increasing the width or height of the scrollable area. You can provide a single number, which will apply to all sides, or an array of two or four numbers to specify spacing for specific directions.<br />
365
- <br />
366
- ⚠ Note:<br />
280
+ <strong>Type:</strong> number[]<br />
281
+ <br />
282
+ <strong>Description:</strong> <em><br />
283
+ This parameter sets the width and height of the <code>MorphScroll</code> component as an array of two numbers. These values help define the visual container for the scrollable area.<br />
284
+ <br />
285
+ If this parameter is not specified, <code>MorphScroll</code> will use 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.<br />
286
+ <br />
287
+ ⚠ Note:<br />
288
+ <ul>
289
+ <li>The values are specified following the <code>width/height</code> rule in pixels, regardless of the <code>direction</code>.</li>
290
+ <li>See the <code>ResizeTracker</code> section for more details.</li>
291
+ </ul></em><br />
292
+ <br />
293
+ <strong>Example:</strong>
294
+
295
+ ```tsx
296
+ <MorphScroll
297
+ size={[100, 400]}
298
+ // another props
299
+ >
300
+ {children}
301
+ </MorphScroll>
302
+ ```
303
+
304
+ </ul>
305
+
306
+ </details>
307
+
308
+ <h2></h2>
309
+
310
+ <details>
311
+ <summary><strong><code>objectsSize</code> (required)</strong>: <em>Required: Size of cells for each object.</em></summary><br />
367
312
  <ul>
368
- <li>
369
- This parameter accepts either a single number or an array of numbers
370
- <ul>
371
- <li>If a two-number array is provided, the values follow the <code>horizontal/vertical</code> rule.</li>
372
- <li>If a four-number array is provided, the values follow the <code>top/right/bottom/left</code> rule.</li>
373
- </ul>
374
- </li>
375
- <li>All values are in pixels and apply regardless of the <code>direction</code>.</li>
376
- <li>This is not a CSS property, even though its name might suggest otherwise. It specifically refers to modifying the width and height of the scrollable wrapper, affecting the dimensions of the scrollable area.</li>
377
- </ul></em><br />
378
- <br />
379
- <strong>Example:</strong>
380
-
381
- ```tsx
382
- <MorphScroll
383
- padding={10}
384
- // padding={[10, 10]}
385
- // padding={[10, 10, 10, 10]}
386
- // another props
387
- >
388
- {children}
389
- </MorphScroll>
390
- ```
391
-
392
- </ul>
393
- </details>
394
-
395
- <h2></h2>
396
-
397
- <details>
398
- <summary><strong><code>contentAlign</code></strong>: <em>Aligns the content when it is smaller than the MorphScroll <code>size</code>.</em></summary><br />
399
- <ul>
400
- <strong>Type:</strong> [<br />
401
- "start" | "center" | "end",<br />
402
- "start" | "center" | "end"<br />
403
- ]<br />
404
- <strong>Description:</strong> <em><br />
405
- This parameter aligns the `objectsWrapper`, which contains all the provided elements, relative to the scroll or the `size`.<br />
406
- <br />
407
- ⚠ Note:<br />
313
+ <strong>Type:</strong> (number | "none" | "firstChild")[]<br />
314
+ <br />
315
+ <strong>Description:</strong> <em><br />
316
+ This parameter is the only required one. It defines the size of cells for each of your objects. <code>ObjectsSize</code> use an array of values.<br />
317
+ <br />
318
+ If you pass <code>"none"</code>, cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects. In this case, for example, you won’t be able to use the <code>infiniteScroll</code> feature, as it requires specific cell sizes for absolute positioning.. However, this is not a drawback if you are building something like a chat or a news feed, where the content can have varying heights, and it’s better to load new content as the user approaches the end of the existing list.<br />
319
+ <br />
320
+ If you specify the value <code>"firstChild"</code>, a <code>ResizeTracker</code> wrapper will be created 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 />
321
+ <br />
322
+ ⚠ Note:<br />
323
+ The numbers are specified following the <code>width/height</code> rule, regardless of the <code>direction</code>.</em><br />
324
+ <br />
325
+ <strong>Example:</strong>
326
+
327
+ ```tsx
328
+ <MorphScroll
329
+ objectsSize={[40, 40]}
330
+ // objectsSize={["none", "none"]}
331
+ // objectsSize={["firstChild", "firstChild"]}
332
+ // another props
333
+ >
334
+ {children}
335
+ </MorphScroll>
336
+ ```
337
+
338
+ </ul>
339
+
340
+ </details>
341
+
342
+ <h2></h2>
343
+
344
+ <details>
345
+ <summary><strong><code>gap</code></strong>: <em>Gap between cells.</em></summary><br />
408
346
  <ul>
409
- <li>Only takes effect when `objectsWrapper` is smaller than the scroll container.
410
- </li>
411
- <li>The values are specified following the horizontal/vertical rule, regardless of the direction.
412
- </li>
413
- </ul></em><br />
414
- <br />
415
- <strong>Example:</strong>
416
-
417
- ```tsx
418
- <MorphScroll
419
- contentAlign={["center", "center"]}
420
- // another props
421
- >
422
- {children}
423
- </MorphScroll>
424
- ```
425
-
426
- </ul>
427
- </details>
428
-
429
- <h2></h2>
430
-
431
- <details>
432
- <summary><strong><code>elementsAlign</code></strong>: <em>Aligns the objects within the <code>objectsWrapper</code>.</em></summary><br />
433
- <ul>
434
- <strong>Type:</strong> "start" | "center" | "end"<br />
435
- <br />
436
- <strong>Example:</strong>
437
-
438
- ```tsx
439
- <MorphScroll
440
- elementsAlign="center"
441
- // another props
442
- >
443
- {children}
444
- </MorphScroll>
445
- ```
446
-
447
- </ul>
448
- </details>
449
-
450
- <h2></h2>
451
-
452
- <details>
453
- <summary><strong><code>edgeGradient</code></strong>: <em>Gradient when scrolling overflows.</em></summary><br />
454
- <ul>
455
- <strong>Type:</strong> boolean | { color?: string; size?: number }<br />
456
- <br />
457
- <strong>Default:</strong> When using true or color, the default size will be 40<br />
458
- <br />
459
- <strong>Description:</strong> <em><br />
460
- This parameter creates two edge elements responsible for darkening the edges of the scroll when it overflows.<br />
461
- <br />
462
- The color property accepts any valid color format. If specified, the library will generate a gradient transitioning from the custom color to transparent. If omitted, the edge elements will have no color, allowing for custom styling via CSS classes.<br />
463
- <br />
464
- ⚠ Note:<br />
465
- The size property, measured in pixels, adjusts the dimensions of the edge elements.</em><br />
466
- <br />
467
- <strong>Example:</strong>
468
-
469
- ```tsx
470
- <MorphScroll
471
- edgeGradient={{ color: "rgba(0, 0, 0, 0.5)" }}
472
- // edgeGradient={{ color: "rgba(0, 0, 0, 0.5)", size: 20 }}
473
- // edgeGradient
474
- // another props
475
- >
476
- {children}
477
- </MorphScroll>
478
- ```
479
-
480
- </ul>
481
- </details>
482
-
483
- <h2></h2>
484
-
485
- <details>
486
- <summary><strong><code>progressReverse</code></strong>: <em>Reverse the progress bar position.</em></summary><br />
487
- <ul>
488
- <strong>Type:</strong> boolean<br />
489
- <br />
490
- <strong>Default:</strong> false<br />
491
- <br />
492
- <strong>Description:</strong> <em><br />
493
- This parameter changes the position of the progress bar based on the direction property.<br />
347
+ <strong>Type:</strong> number[] | number<br />
348
+ <br />
349
+ <strong>Description:</strong> <em><br />
350
+ This parameter allows you to set spacing between list items both horizontally and vertically. You can provide a single value, which will apply to both directions, or an array of two numbers to define separate spacing values.<br />
351
+ <br />
352
+ ⚠ Note:<br />
353
+ The values are specified following the <code>horizontal/vertical</code> rule in pixels, regardless of the <code>direction</code>.</em><br />
354
+ <br />
355
+ <strong>Example:</strong>
356
+
357
+ ```tsx
358
+ <MorphScroll
359
+ gap={10}
360
+ // gap={[10, 10]}
361
+ // another props
362
+ >
363
+ {children}
364
+ </MorphScroll>
365
+ ```
366
+
367
+ </ul>
368
+
369
+ </details>
370
+
371
+ <h2></h2>
372
+
373
+ <details>
374
+ <summary><strong><code>padding</code></strong>: <em>Padding for the <code>objectsWrapper</code>.</em></summary><br />
494
375
  <ul>
495
- <li>If <code>direction="x"</code>, the progress bar is on the left by default and moves to the right when <code>progressReverse</code> is enabled.</li>
496
- <li>If <code>direction="y"</code>, the progress bar is at the top by default and moves to the bottom when <code>progressReverse</code> is enabled.</li>
497
- </ul></em><br />
498
- <br />
499
- <strong>Example:</strong>
500
-
501
- ```tsx
502
- <MorphScroll
503
- progressReverse
504
- // another props
505
- >
506
- {children}
507
- </MorphScroll>
508
- ```
509
-
510
- </ul>
511
- </details>
512
-
513
- <h2></h2>
514
-
515
- <details>
516
- <summary><strong><code>progressVisibility</code></strong>: <em>Visibility of the progress bar.</em></summary><br />
517
- <ul>
518
- <strong>Type:</strong> "visible" | "hover" | "hidden"<br />
519
- <br />
520
- <strong>Default:</strong> "visible"<br />
521
- <br />
522
- <strong>Description:</strong> <em><br />
523
- This parameter controls the visibility of the progress bar regardless of the <code>type</code> value.</em><br />
524
- <br />
525
- <strong>Example:</strong>
526
-
527
- ```tsx
528
- <MorphScroll
529
- progressVisibility="hover"
530
- // another props
531
- >
532
- {children}
533
- </MorphScroll>
534
- ```
535
-
536
- </ul>
537
- </details>
538
-
539
- <h2></h2>
540
-
541
- <details>
542
- <summary><strong><code>objectsWrapFullMinSize</code></strong>: <em>Sets the <code>min-height</code> CSS property of the <code>objectsWrapper</code> to match the height of the MorphScroll.</em></summary><br />
543
- <ul>
544
- <strong>Type:</strong> boolean<br /><br />
545
- <strong>Default:</strong> false<br /><br />
546
- <strong>Description:</strong> <em><br />
547
- In process of development</em><br />
548
- <br />
549
- <strong>Example:</strong>
550
-
551
- ```tsx
552
- <MorphScroll
553
- objectsWrapFullMinSize
554
- // another props
555
- >
556
- {children}
557
- </MorphScroll>
558
- ```
376
+ <strong>Type:</strong> number[] | number<br />
377
+ <br />
378
+ <strong>Description:</strong> <em><br />
379
+ This parameter defines the spacing between the list items and their wrapper, effectively increasing the width or height of the scrollable area. You can provide a single number, which will apply to all sides, or an array of two or four numbers to specify spacing for specific directions.<br />
380
+ <br />
381
+ ⚠ Note:<br />
382
+ <ul>
383
+ <li>
384
+ This parameter accepts either a single number or an array of numbers
385
+ <ul>
386
+ <li>If a two-number array is provided, the values follow the <code>horizontal/vertical</code> rule.</li>
387
+ <li>If a four-number array is provided, the values follow the <code>top/right/bottom/left</code> rule.</li>
388
+ </ul>
389
+ </li>
390
+ <li>All values are in pixels and apply regardless of the <code>direction</code>.</li>
391
+ <li>This is not a CSS property, even though its name might suggest otherwise. It specifically refers to modifying the width and height of the scrollable wrapper, affecting the dimensions of the scrollable area.</li>
392
+ </ul></em><br />
393
+ <br />
394
+ <strong>Example:</strong>
395
+
396
+ ```tsx
397
+ <MorphScroll
398
+ padding={10}
399
+ // padding={[10, 10]}
400
+ // padding={[10, 10, 10, 10]}
401
+ // another props
402
+ >
403
+ {children}
404
+ </MorphScroll>
405
+ ```
406
+
407
+ </ul>
408
+
409
+ </details>
410
+
411
+ <h2></h2>
412
+
413
+ <details>
414
+ <summary><strong><code>contentAlign</code></strong>: <em>Aligns the content when it is smaller than the MorphScroll <code>size</code>.</em></summary><br />
415
+ <ul>
416
+ <strong>Type:</strong> [<br />
417
+ "start" | "center" | "end",<br />
418
+ "start" | "center" | "end"<br />
419
+ ]<br />
420
+ <strong>Description:</strong> <em><br />
421
+ This parameter aligns the `objectsWrapper`, which contains all the provided elements, relative to the scroll or the `size`.<br />
422
+ <br />
423
+ Note:<br />
424
+ <ul>
425
+ <li>Only takes effect when `objectsWrapper` is smaller than the scroll container.
426
+ </li>
427
+ <li>The values are specified following the horizontal/vertical rule, regardless of the direction.
428
+ </li>
429
+ </ul></em><br />
430
+ <br />
431
+ <strong>Example:</strong>
432
+
433
+ ```tsx
434
+ <MorphScroll
435
+ contentAlign={["center", "center"]}
436
+ // another props
437
+ >
438
+ {children}
439
+ </MorphScroll>
440
+ ```
441
+
442
+ </ul>
443
+
444
+ </details>
445
+
446
+ <h2></h2>
447
+
448
+ <details>
449
+ <summary><strong><code>elementsAlign</code></strong>: <em>Aligns the objects within the <code>objectsWrapper</code>.</em></summary><br />
450
+ <ul>
451
+ <strong>Type:</strong> "start" | "center" | "end"<br />
452
+ <br />
453
+ <strong>Example:</strong>
454
+
455
+ ```tsx
456
+ <MorphScroll
457
+ elementsAlign="center"
458
+ // another props
459
+ >
460
+ {children}
461
+ </MorphScroll>
462
+ ```
463
+
464
+ </ul>
465
+
466
+ </details>
467
+
468
+ <h2></h2>
469
+
470
+ <details>
471
+ <summary><strong><code>edgeGradient</code></strong>: <em>Gradient when scrolling overflows.</em></summary><br />
472
+ <ul>
473
+ <strong>Type:</strong> boolean | { color?: string; size?: number }<br />
474
+ <br />
475
+ <strong>Default:</strong> When using true or color, the default size will be 40<br />
476
+ <br />
477
+ <strong>Description:</strong> <em><br />
478
+ This parameter creates two edge elements responsible for darkening the edges of the scroll when it overflows.<br />
479
+ <br />
480
+ The color property accepts any valid color format. If specified, the library will generate a gradient transitioning from the custom color to transparent. If omitted, the edge elements will have no color, allowing for custom styling via CSS classes.<br />
481
+ <br />
482
+ ⚠ Note:<br />
483
+ The size property, measured in pixels, adjusts the dimensions of the edge elements.</em><br />
484
+ <br />
485
+ <strong>Example:</strong>
486
+
487
+ ```tsx
488
+ <MorphScroll
489
+ edgeGradient={{ color: "rgba(0, 0, 0, 0.5)" }}
490
+ // edgeGradient={{ color: "rgba(0, 0, 0, 0.5)", size: 20 }}
491
+ // edgeGradient
492
+ // another props
493
+ >
494
+ {children}
495
+ </MorphScroll>
496
+ ```
497
+
498
+ </ul>
499
+
500
+ </details>
501
+
502
+ <h2></h2>
503
+
504
+ <details>
505
+ <summary><strong><code>progressReverse</code></strong>: <em>Reverse the progress bar position.</em></summary><br />
506
+ <ul>
507
+ <strong>Type:</strong> boolean<br />
508
+ <br />
509
+ <strong>Default:</strong> false<br />
510
+ <br />
511
+ <strong>Description:</strong> <em><br />
512
+ This parameter changes the position of the progress bar based on the direction property.<br />
513
+ <ul>
514
+ <li>If <code>direction="x"</code>, the progress bar is on the left by default and moves to the right when <code>progressReverse</code> is enabled.</li>
515
+ <li>If <code>direction="y"</code>, the progress bar is at the top by default and moves to the bottom when <code>progressReverse</code> is enabled.</li>
516
+ </ul></em><br />
517
+ <br />
518
+ <strong>Example:</strong>
519
+
520
+ ```tsx
521
+ <MorphScroll
522
+ progressReverse
523
+ // another props
524
+ >
525
+ {children}
526
+ </MorphScroll>
527
+ ```
528
+
529
+ </ul>
530
+
531
+ </details>
559
532
 
560
- </ul>
561
- </details>
533
+ <h2></h2>
562
534
 
563
- <h2></h2>
535
+ <details>
536
+ <summary><strong><code>progressVisibility</code></strong>: <em>Visibility of the progress bar.</em></summary><br />
537
+ <ul>
538
+ <strong>Type:</strong> "visible" | "hover" | "hidden"<br />
539
+ <br />
540
+ <strong>Default:</strong> "visible"<br />
541
+ <br />
542
+ <strong>Description:</strong> <em><br />
543
+ This parameter controls the visibility of the progress bar regardless of the <code>type</code> value.</em><br />
544
+ <br />
545
+ <strong>Example:</strong>
546
+
547
+ ```tsx
548
+ <MorphScroll
549
+ progressVisibility="hover"
550
+ // another props
551
+ >
552
+ {children}
553
+ </MorphScroll>
554
+ ```
555
+
556
+ </ul>
557
+
558
+ </details>
559
+
560
+ <h2></h2>
561
+
562
+ <details>
563
+ <summary><strong><code>objectsWrapFullMinSize</code></strong>: <em>Sets the <code>min-height</code> CSS property of the <code>objectsWrapper</code> to match the height of the MorphScroll.</em></summary><br />
564
+ <ul>
565
+ <strong>Type:</strong> boolean<br /><br />
566
+ <strong>Default:</strong> false<br /><br />
567
+ <strong>Description:</strong> <em><br />
568
+ In process of development</em><br />
569
+ <br />
570
+ <strong>Example:</strong>
571
+
572
+ ```tsx
573
+ <MorphScroll
574
+ objectsWrapFullMinSize
575
+ // another props
576
+ >
577
+ {children}
578
+ </MorphScroll>
579
+ ```
580
+
581
+ </ul>
582
+
583
+ </details>
584
+
585
+ <h2></h2>
564
586
 
565
587
  #### PROGRESS AND RENDERING:
566
588
 
567
- <details>
568
- <summary><strong><code>progressTrigger</code></strong>: <em>Triggers for the progress bar.</em></summary><br />
569
- <ul>
570
- <strong>Type:</strong> {<br />
571
- wheel?: boolean;<br />
572
- content?: boolean;<br />
573
- progressElement?: boolean | React.ReactNode;<br />
574
- arrows?: boolean | { size?: number; element?: React.ReactNode };<br />
575
- }<br />
576
- <br />
577
- <strong>Default:</strong> { wheel: true }<br />
578
- <br />
579
- <strong>Description:</strong> <em><br />
580
- This is one of the most important parameters, allowing you to define how users interact with the progress bar and customize its appearance.<br />
581
- <br />
589
+ <details>
590
+ <summary><strong><code>progressTrigger</code></strong>: <em>Triggers for the progress bar.</em></summary><br />
582
591
  <ul>
583
- <li>The <code>wheel</code> property determines whether the progress bar responds to mouse wheel scrolling.</li>
584
- <li>The <code>content</code> property enables interaction by clicking and dragging anywhere within the scrollable content to move it.</li>
585
- <li>The <code>progressElement</code> property defines whether the progress bar is controlled by a custom element. If your custom scroll element is not ready yet, you can simply pass <code>true</code>, which will display the browser's default scrollbar when <code>type="scroll"</code> is used. Alternatively, if <code>type="slider"</code> is set, a <code>sliderBar</code> element will be created, containing multiple <code>sliderElem</code> elements representing progress. Depending on the position, one of these elements will always have the <code>active</code> class.</li>
586
- <li>The <code>arrows</code> property 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 <code>element</code>.</li>
587
- </ul></em><br />
588
- <br />
589
- <strong>Example:</strong>
590
-
591
- ```tsx
592
- <MorphScroll
593
- progressTrigger={{
594
- wheel: true,
595
- progressElement: <div className="your-scroll-thumb" />,
596
- }}
597
- // another props
598
- >
599
- {children}
600
- </MorphScroll>
601
- ```
602
-
603
- </ul>
604
- </details>
605
-
606
- <h2></h2>
607
-
608
- <details>
609
- <summary><strong><code>render</code></strong>: <em>Types of rendering for optimization.</em></summary><br />
610
- <ul>
611
- <strong>Type:</strong><br />
612
- | { type: "default" }<br />
613
- | { type: "lazy"; rootMargin?: number | number[]; onVisible?: (key: string) => void }<br />
614
- | { type: "virtual"; rootMargin?: number | number[] }<br />
615
- <br />
616
- <strong>Default:</strong> { type: "default" }<br />
617
- <br />
618
- <strong>Description:</strong> <em><br />
619
- This parameter defines the rendering type for optimization.<br />
620
- <br />
592
+ <strong>Type:</strong> {<br />
593
+ wheel?: boolean;<br />
594
+ content?: boolean;<br />
595
+ progressElement?: boolean | React.ReactNode;<br />
596
+ arrows?: boolean | { size?: number; element?: React.ReactNode };<br />
597
+ }<br />
598
+ <br />
599
+ <strong>Default:</strong> { wheel: true }<br />
600
+ <br />
601
+ <strong>Description:</strong> <em><br />
602
+ This is one of the most important parameters, allowing you to define how users interact with the progress bar and customize its appearance.<br />
603
+ <br />
604
+ <ul>
605
+ <li>The <code>wheel</code> property determines whether the progress bar responds to mouse wheel scrolling.</li>
606
+ <li>The <code>content</code> property enables interaction by clicking and dragging anywhere within the scrollable content to move it.</li>
607
+ <li>The <code>progressElement</code> property defines whether the progress bar is controlled by a custom element. If your custom scroll element is not ready yet, you can simply pass <code>true</code>, which will display the browser's default scrollbar when <code>type="scroll"</code> is used. Alternatively, if <code>type="slider"</code> is set, a <code>sliderBar</code> element will be created, containing multiple <code>sliderElem</code> elements representing progress. Depending on the position, one of these elements will always have the <code>active</code> class.</li>
608
+ <li>The <code>arrows</code> property 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 <code>element</code>.</li>
609
+ </ul></em><br />
610
+ <br />
611
+ <strong>Example:</strong>
612
+
613
+ ```tsx
614
+ <MorphScroll
615
+ progressTrigger={{
616
+ wheel: true,
617
+ progressElement: <div className="your-scroll-thumb" />,
618
+ }}
619
+ // another props
620
+ >
621
+ {children}
622
+ </MorphScroll>
623
+ ```
624
+
625
+ </ul>
626
+
627
+ </details>
628
+
629
+ <h2></h2>
630
+
631
+ <details>
632
+ <summary><strong><code>render</code></strong>: <em>Types of rendering for optimization.</em></summary><br />
621
633
  <ul>
622
- <li>With <code>default</code>, no optimizations are applied.</li>
623
- <li>With <code>lazy</code>, containers are created but do not load content until they enter the viewport. The <code>rootMargin</code> property controls the threshold for loading, and the <code>onVisible</code> callback function can be used to trigger actions when a container becomes visible for each scrollable object and provides the key of the first element in the container.</li>
624
- <li>With <code>virtual</code>, a container is created for each scrollable object, and its absolute positioning is calculated based on <code>scrollTop</code> and scroll area dimensions. Rendering is dynamically adjusted according to the scroll position. The <code>rootMargin</code> property can also be used to extend the rendering area.</li>
625
- </ul><br />
626
- <br />
627
- Note:<br />
634
+ <strong>Type:</strong><br />
635
+ | { type: "default" }<br />
636
+ | { type: "lazy"; rootMargin?: number | number[]; onVisible?: (key: string) => void }<br />
637
+ | { type: "virtual"; rootMargin?: number | number[] }<br />
638
+ <br />
639
+ <strong>Default:</strong> { type: "default" }<br />
640
+ <br />
641
+ <strong>Description:</strong> <em><br />
642
+ This parameter defines the rendering type for optimization.<br />
643
+ <br />
644
+ <ul>
645
+ <li>With <code>default</code>, no optimizations are applied.</li>
646
+ <li>With <code>lazy</code>, containers are created but do not load content until they enter the viewport. The <code>rootMargin</code> property controls the threshold for loading, and the <code>onVisible</code> callback function can be used to trigger actions when a container becomes visible for each scrollable object and provides the key of the first element in the container.</li>
647
+ <li>With <code>virtual</code>, a container is created for each scrollable object, and its absolute positioning is calculated based on <code>scrollTop</code> and scroll area dimensions. Rendering is dynamically adjusted according to the scroll position. The <code>rootMargin</code> property can also be used to extend the rendering area.</li>
648
+ </ul><br />
649
+ <br />
650
+ ⚠ Note:<br />
651
+ <ul>
652
+ <li>The <code>onVisible</code> property is the same as in <code>IntersectionTracker/onVisible</code>.</li>
653
+ <li>
654
+ The <code>rootMargin</code> property accepts either a single number or an array of numbers.
655
+ <ul>
656
+ <li>If a two-number array is provided, the values follow the <code>horizontal/vertical</code> rule.</li>
657
+ <li>If a four-number array is provided, the values follow the <code>top/right/bottom/left</code> rule.</li>
658
+ </ul>
659
+ </li>
660
+ <li>All values are in pixels and apply regardless of the <code>direction</code>.</li>
661
+ </ul></em><br />
662
+ <br />
663
+ <strong>Example:</strong>
664
+
665
+ ```tsx
666
+ <MorphScroll
667
+ render={{ type: "virtual" }}
668
+ // render={{
669
+ // type: "lazy",
670
+ // rootMargin: [0, 100],
671
+ // onVisible: () => console.log("visible"))
672
+ // }}
673
+ // another props
674
+ >
675
+ {children}
676
+ </MorphScroll>
677
+ ```
678
+
679
+ </ul>
680
+
681
+ </details>
682
+
683
+ <h2></h2>
684
+
685
+ <details>
686
+ <summary><strong><code>emptyElements</code></strong>: <em>Handling of empty scroll elements.</em></summary><br />
628
687
  <ul>
629
- <li>The <code>onVisible</code> property is the same as in <code>IntersectionTracker/onVisible</code>.</li>
630
- <li>
631
- The <code>rootMargin</code> property accepts either a single number or an array of numbers.
632
- <ul>
633
- <li>If a two-number array is provided, the values follow the <code>horizontal/vertical</code> rule.</li>
634
- <li>If a four-number array is provided, the values follow the <code>top/right/bottom/left</code> rule.</li>
635
- </ul>
636
- </li>
637
- <li>All values are in pixels and apply regardless of the <code>direction</code>.</li>
638
- </ul></em><br />
639
- <br />
640
- <strong>Example:</strong>
641
-
642
- ```tsx
643
- <MorphScroll
644
- render={{ type: "virtual" }}
645
- // render={{
646
- // type: "lazy",
647
- // rootMargin: [0, 100],
648
- // onVisible: () => console.log("visible"))
649
- // }}
650
- // another props
651
- >
652
- {children}
653
- </MorphScroll>
654
- ```
655
-
656
- </ul>
657
- </details>
658
-
659
- <h2></h2>
660
-
661
- <details>
662
- <summary><strong><code>emptyElements</code></strong>: <em>Handling of empty scroll elements.</em></summary><br />
663
- <ul>
664
- <strong>Type:</strong><br />
665
- | {
666
- mode: "clear";
667
- clickTrigger?: { selector: string; delay?: number };
668
- }<br />
669
- | {
670
- mode: "fallback";
671
- element?: React.ReactNode;
672
- clickTrigger?: { selector: string; delay?: number };
673
- }<br /><br />
674
- <strong>Description:</strong> <em><br />
675
- If certain components might return nothing during rendering, this parameter helps manage them. The check and subsequent replacement with a fallback element or removal occur after the scroll elements are rendered. Due to this, when dynamically displaying elements in different <code>render</code> modes, you may notice slight position shifts during fast scrolling, as empty elements are removed, causing subsequent elements to reposition.<br />
676
- <br />
688
+ <strong>Type:</strong><br />
689
+ | {
690
+ mode: "clear";
691
+ clickTrigger?: { selector: string; delay?: number };
692
+ }<br />
693
+ | {
694
+ mode: "fallback";
695
+ element?: React.ReactNode;
696
+ clickTrigger?: { selector: string; delay?: number };
697
+ }<br /><br />
698
+ <strong>Description:</strong> <em><br />
699
+ If certain components might return nothing during rendering, this parameter helps manage them. The check and subsequent replacement with a fallback element or removal occur after the scroll elements are rendered. Due to this, when dynamically displaying elements in different <code>render</code> modes, you may notice slight position shifts during fast scrolling, as empty elements are removed, causing subsequent elements to reposition.<br />
700
+ <br />
701
+ <ul>
702
+ <li><code>mode: "clear"</code> – automatically removes empty elements, eliminating unnecessary gaps in the scroll list.</li>
703
+ <li><code>mode: "fallback"</code> – replaces empty elements with a specified fallback component. By default, it uses the <code>fallback</code> props value, but you can also pass a separate placeholder to <code>element</code>.</li>
704
+ </ul><br />
705
+ <br />
706
+ <code>clickTrigger</code> – if elements are removed via a click action, this property ensures cleanup is triggered accordingly. It accepts an object with a <code>selector</code> (such as a delete button’s class) and an optional <code>delay</code> (a delay in milliseconds to accommodate animations or complex removals).<br />
707
+ <br />
708
+ Note:<br />
709
+ For clarification, the cleanup will occur on the initial render, when the number of passed elements changes, on scroll, and on click if you use <code>clickTrigger</code>.</em><br />
710
+ <br />
711
+ <strong>Example:</strong>
712
+
713
+ ```tsx
714
+ <MorphScroll
715
+ emptyElements={{
716
+ mode: "clear",
717
+ clickTrigger: { selector: ".close-button" },
718
+ }}
719
+ // emptyElements={{
720
+ // mode: "fallback",
721
+ // clickTrigger: {
722
+ // selector: ".close-button",
723
+ // delay: 100,
724
+ // },
725
+ // }}
726
+ // another props
727
+ >
728
+ {children}
729
+ </MorphScroll>
730
+ ```
731
+
732
+ </ul>
733
+
734
+ </details>
735
+
736
+ <h2></h2>
737
+
738
+ <details>
739
+ <summary><strong><code>suspending</code></strong>: <em>Adds React Suspense.</em></summary><br />
677
740
  <ul>
678
- <li><code>mode: "clear"</code> automatically removes empty elements, eliminating unnecessary gaps in the scroll list.</li>
679
- <li><code>mode: "fallback"</code> – replaces empty elements with a specified fallback component. By default, it uses the <code>fallback</code> props value, but you can also pass a separate placeholder to <code>element</code>.</li>
680
- </ul><br />
681
- <br />
682
- <code>clickTrigger</code> – if elements are removed via a click action, this property ensures cleanup is triggered accordingly. It accepts an object with a <code>selector</code> (such as a delete button’s class) and an optional <code>delay</code> (a delay in milliseconds to accommodate animations or complex removals).<br />
683
- <br />
684
- ⚠ Note:<br />
685
- For clarification, the cleanup will occur on the initial render, when the number of passed elements changes, on scroll, and on click if you use <code>clickTrigger</code>.</em><br />
686
- <br />
687
- <strong>Example:</strong>
688
-
689
- ```tsx
690
- <MorphScroll
691
- emptyElements={{
692
- mode: "clear",
693
- clickTrigger: { selector: ".close-button" },
694
- }}
695
- // emptyElements={{
696
- // mode: "fallback",
697
- // clickTrigger: {
698
- // selector: ".close-button",
699
- // delay: 100,
700
- // },
701
- // }}
702
- // another props
703
- >
704
- {children}
705
- </MorphScroll>
706
- ```
707
-
708
- </ul>
709
- </details>
710
-
711
- <h2></h2>
712
-
713
- <details>
714
- <summary><strong><code>suspending</code></strong>: <em>Adds React Suspense.</em></summary><br />
715
- <ul>
716
- <strong>Type:</strong> boolean<br />
717
- <br />
718
- <strong>Default:</strong> false<br />
719
- <br />
720
- <strong>Description:</strong> <em><br />
721
- This parameter adds React Suspense to the MorphScroll component for asynchronous rendering.</em><br />
722
- <br />
723
- <strong>Example:</strong>
724
-
725
- ```tsx
726
- <MorphScroll
727
- suspending
728
- // another props
729
- >
730
- {children}
731
- </MorphScroll>
732
- ```
733
-
734
- </ul>
735
- </details>
736
-
737
- <h2></h2>
738
-
739
- <details>
740
- <summary><strong><code>fallback</code></strong>: <em>Fallback element.</em></summary><br />
741
- <ul>
742
- <strong>Type:</strong> React.ReactNode<br />
743
- <br />
744
- <strong>Description:</strong> <em><br />
745
- This parameter sets the fallback element for custom element. It will be used for <code>emptyElements</code> in <code>mode: "fallback"</code> or when <code>suspending</code> is enabled.</em><br />
746
- <br />
747
- <strong>Example:</strong>
748
-
749
- ```tsx
750
- <MorphScroll
751
- fallback={<div>Loading...</div>}
752
- // another props
753
- >
754
- {children}
755
- </MorphScroll>
756
- ```
741
+ <strong>Type:</strong> boolean<br />
742
+ <br />
743
+ <strong>Default:</strong> false<br />
744
+ <br />
745
+ <strong>Description:</strong> <em><br />
746
+ This parameter adds React Suspense to the MorphScroll component for asynchronous rendering.</em><br />
747
+ <br />
748
+ <strong>Example:</strong>
749
+
750
+ ```tsx
751
+ <MorphScroll
752
+ suspending
753
+ // another props
754
+ >
755
+ {children}
756
+ </MorphScroll>
757
+ ```
758
+
759
+ </ul>
760
+
761
+ </details>
762
+
763
+ <h2></h2>
764
+
765
+ <details>
766
+ <summary><strong><code>fallback</code></strong>: <em>Fallback element.</em></summary><br />
767
+ <ul>
768
+ <strong>Type:</strong> React.ReactNode<br />
769
+ <br />
770
+ <strong>Description:</strong> <em><br />
771
+ This parameter sets the fallback element for custom element. It will be used for <code>emptyElements</code> in <code>mode: "fallback"</code> or when <code>suspending</code> is enabled.</em><br />
772
+ <br />
773
+ <strong>Example:</strong>
774
+
775
+ ```tsx
776
+ <MorphScroll
777
+ fallback={<div>Loading...</div>}
778
+ // another props
779
+ >
780
+ {children}
781
+ </MorphScroll>
782
+ ```
783
+
784
+ </ul>
757
785
 
758
- </ul>
759
- </details>
786
+ </details>
787
+
788
+ </div>
760
789
 
761
790
  <h2></h2>
762
791
 
@@ -766,129 +795,133 @@ npm install morphing-scroll
766
795
 
767
796
  - ### Props:
768
797
 
769
- <details>
770
- <summary><strong><code>children</code></strong>: <em>Render-prop function for size updates and adding content.</em></summary><br />
771
- <ul>
772
- <strong>Type:</strong> (rect: DOMRectReadOnly) => React.ReactNode<br />
773
- <br />
774
- <strong>Description:</strong> <em><br />
775
- Instead of a standard <code>children</code> prop, this component uses a <strong>render-prop function</strong> to pass size updates to its children. You can use it similarly to a regular <code>children</code> prop inside the component.<br />
776
- <br />
777
- The function receives an object of type <code>DOMRectReadOnly</code> with the following properties:
798
+ <div>
799
+
800
+ <details>
801
+ <summary><strong><code>children</code></strong>: <em>Render-prop function for size updates and adding content.</em></summary><br />
802
+ <ul>
803
+ <strong>Type:</strong> (rect: DOMRectReadOnly) => React.ReactNode<br />
804
+ <br />
805
+ <strong>Description:</strong> <em><br />
806
+ Instead of a standard <code>children</code> prop, this component uses a <strong>render-prop function</strong> to pass size updates to its children. You can use it similarly to a regular <code>children</code> prop inside the component.<br />
807
+ <br />
808
+ The function receives an object of type <code>DOMRectReadOnly</code> with the following properties:
809
+ <ul>
810
+ <li><code>x</code> - The X-coordinate of the top-left corner of the element.</li>
811
+ <li><code>y</code> - The Y-coordinate of the top-left corner of the element.</li>
812
+ <li><code>width</code> - The width of the observed element’s content box.</li>
813
+ <li><code>height</code> - The height of the observed element’s content box.</li>
814
+ <li><code>top</code> - The distance from the top of the element to its parent's top. Equal to <code>y</code>.</li>
815
+ <li><code>left</code> - The distance from the left of the element to its parent's left. Equal to <code>x</code>.</li>
816
+ <li><code>right</code> - The distance from the left of the parent to the right edge of the element (<code>left</code> + <code>width</code>).</li>
817
+ <li><code>bottom</code> - The distance from the top of the parent to the bottom edge of the element (<code>top</code> + <code>height</code>).</li>
818
+ </ul><br />
819
+ <br />
820
+ ⚠ This is a non-standard prop that you might be used to using this is render-prop function receiving the container's size.</em><br />
821
+ <br />
822
+ <strong>Example:</strong>
823
+
824
+ ```tsx
825
+ <ResizeTracker
826
+ // another props
827
+ >
828
+ {(rect) => (
829
+ <p>
830
+ Width: {rect.width}, Height: {rect.height}
831
+ </p>
832
+ )}
833
+ </ResizeTracker>
834
+ ```
835
+
836
+ </ul>
837
+
838
+ </details>
839
+
840
+ <h2></h2>
841
+
842
+ <details>
843
+ <summary><strong><code>style</code></strong>: <em>Applies inline styles to the container.</em></summary><br />
844
+ <ul>
845
+ <strong>Type:</strong> React.CSSProperties<br />
846
+ <br />
847
+ <strong>Example:</strong>
848
+
849
+ ```tsx
850
+ <ResizeTracker style={{ backgroundColor: "blue" }}>
851
+ {(rect) => (
852
+ // content
853
+ )}
854
+ </ResizeTracker>
855
+ ```
856
+
857
+ </ul>
858
+
859
+ </details>
860
+
861
+ <h2></h2>
862
+
863
+ <details>
864
+ <summary><strong><code>measure</code></strong>: <em>Defines the measurement strategy.</em></summary><br />
778
865
  <ul>
779
- <li><code>x</code> - The X-coordinate of the top-left corner of the element.</li>
780
- <li><code>y</code> - The Y-coordinate of the top-left corner of the element.</li>
781
- <li><code>width</code> - The width of the observed element’s content box.</li>
782
- <li><code>height</code> - The height of the observed element’s content box.</li>
783
- <li><code>top</code> - The distance from the top of the element to its parent's top. Equal to <code>y</code>.</li>
784
- <li><code>left</code> - The distance from the left of the element to its parent's left. Equal to <code>x</code>.</li>
785
- <li><code>right</code> - The distance from the left of the parent to the right edge of the element (<code>left</code> + <code>width</code>).</li>
786
- <li><code>bottom</code> - The distance from the top of the parent to the bottom edge of the element (<code>top</code> + <code>height</code>).</li>
787
- </ul><br />
788
- <br />
789
- ⚠ This is a non-standard prop that you might be used to using this is render-prop function receiving the container's size.</em><br />
790
- <br />
791
- <strong>Example:</strong>
792
-
793
- ```tsx
794
- <ResizeTracker
795
- // another props
796
- >
797
- {(rect) => (
798
- <p>
799
- Width: {rect.width}, Height: {rect.height}
800
- </p>
801
- )}
802
- </ResizeTracker>
803
- ```
804
-
805
- </ul>
806
-
807
- </details>
808
-
809
- <h2></h2>
810
-
811
- <details>
812
- <summary><strong><code>style</code></strong>: <em>Applies inline styles to the container.</em></summary><br />
813
- <ul>
814
- <strong>Type:</strong> React.CSSProperties<br />
815
- <br />
816
- <strong>Example:</strong>
817
-
818
- ```tsx
819
- <ResizeTracker style={{ backgroundColor: "blue" }}>
820
- {(rect) => (
821
- // content
822
- )}
823
- </ResizeTracker>
824
- ```
825
-
826
- </ul>
827
-
828
- </details>
829
-
830
- <h2></h2>
831
-
832
- <details>
833
- <summary><strong><code>measure</code></strong>: <em>Defines the measurement strategy.</em></summary><br />
834
- <ul>
835
- <strong>Type:</strong> "inner" | "outer" | "all"<br />
836
- <br />
837
- <strong>Default:</strong> "inner"<br />
838
- <br />
839
- <strong>Description:</strong><br />
840
- <em>This prop determines what is being measured by automatically applying inline styles that affect width and height.<br />
841
- <br />
842
- - The default value <code>"inner"</code> sets <code>width: "max-content"</code> and <code>height: "max-content"</code>, measuring the size of child elements.<br />
843
- - The <code>"outer"</code> value measures the parent element by setting <code>minWidth: "100%"</code> and <code>minHeight: "100%"</code>.<br />
844
- - The <code>"all"</code> value combines the styles of both <code>"inner"</code> and <code>"outer"</code>, allowing measurement of both the parent and child elements.<br />
845
- <br />
846
- ⚠ Note: 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 />
847
- <br />
848
- <strong>Example:</strong>
849
-
850
- ```tsx
851
- <ResizeTracker measure="all">
852
- {(rect) => (
853
- // content
854
- )}
855
- </ResizeTracker>
856
- ```
857
-
858
- </ul>
859
-
860
- </details>
861
-
862
- <h2></h2>
863
-
864
- <details>
865
- <summary><strong><code>onResize</code></strong>: <em>Callback triggered on size changes.</em></summary><br />
866
- <ul>
867
- <strong>Type:</strong> (rect: Partial<DOMRectReadOnly>) => void<br />
868
- <br />
869
- <strong>Description:</strong><br />
870
- <em>A callback function that is triggered whenever the observed element's dimensions change.<br />
871
- The function receives an object containing the updated size properties.</em><br />
872
- <br />
873
- <strong>Example:</strong>
874
-
875
- ```tsx
876
- <ResizeTracker
877
- onResize={(rect) => {
878
- console.log("New size:", rect);
879
- }}
880
- >
881
- {(rect) => (
882
- // content
883
- )}
884
- </ResizeTracker>
885
- ```
886
-
887
- </ul>
888
-
889
- </details>
890
-
891
- <h2></h2>
866
+ <strong>Type:</strong> "inner" | "outer" | "all"<br />
867
+ <br />
868
+ <strong>Default:</strong> "inner"<br />
869
+ <br />
870
+ <strong>Description:</strong><br />
871
+ <em>This prop determines what is being measured by automatically applying inline styles that affect width and height.<br />
872
+ <br />
873
+ - The default value <code>"inner"</code> sets <code>width: "max-content"</code> and <code>height: "max-content"</code>, measuring the size of child elements.<br />
874
+ - The <code>"outer"</code> value measures the parent element by setting <code>minWidth: "100%"</code> and <code>minHeight: "100%"</code>.<br />
875
+ - The <code>"all"</code> value combines the styles of both <code>"inner"</code> and <code>"outer"</code>, allowing measurement of both the parent and child elements.<br />
876
+ <br />
877
+ ⚠ Note: 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 />
878
+ <br />
879
+ <strong>Example:</strong>
880
+
881
+ ```tsx
882
+ <ResizeTracker measure="all">
883
+ {(rect) => (
884
+ // content
885
+ )}
886
+ </ResizeTracker>
887
+ ```
888
+
889
+ </ul>
890
+
891
+ </details>
892
+
893
+ <h2></h2>
894
+
895
+ <details>
896
+ <summary><strong><code>onResize</code></strong>: <em>Callback triggered on size changes.</em></summary><br />
897
+ <ul>
898
+ <strong>Type:</strong> (rect: Partial<DOMRectReadOnly>) => void<br />
899
+ <br />
900
+ <strong>Description:</strong><br />
901
+ <em>A callback function that is triggered whenever the observed element's dimensions change.<br />
902
+ The function receives an object containing the updated size properties.</em><br />
903
+ <br />
904
+ <strong>Example:</strong>
905
+
906
+ ```tsx
907
+ <ResizeTracker
908
+ onResize={(rect) => {
909
+ console.log("New size:", rect);
910
+ }}
911
+ >
912
+ {(rect) => (
913
+ // content
914
+ )}
915
+ </ResizeTracker>
916
+ ```
917
+
918
+ </ul>
919
+
920
+ </details>
921
+
922
+ <h2></h2>
923
+
924
+ </div>
892
925
 
893
926
  - ### Link:
894
927
 
@@ -902,193 +935,197 @@ npm install morphing-scroll
902
935
 
903
936
  - ### Props:
904
937
 
905
- <details>
906
- <summary><strong><code>children</code></strong>: <em>Custom user content.</em></summary><br />
907
- <ul>
908
- <strong>Type:</strong> React.ReactNode<br />
909
- <br />
910
- <strong>Example:</strong>
911
-
912
- ```tsx
913
- <IntersectionTracker>{children}</IntersectionTracker>
914
- ```
915
-
916
- </ul>
917
-
918
- </details>
919
-
920
- <h2></h2>
921
-
922
- <details>
923
- <summary><strong><code>style</code></strong>: <em>Applies inline styles to the container.</em></summary><br />
924
- <ul>
925
- <strong>Type:</strong> React.CSSProperties<br />
926
- <br />
927
- <strong>Example:</strong>
928
-
929
- ```tsx
930
- <IntersectionTracker style={{ backgroundColor: "blue" }}>
931
- {children}
932
- </IntersectionTracker>
933
- ```
934
-
935
- </ul>
936
-
937
- </details>
938
-
939
- <h2></h2>
940
-
941
- <details>
942
- <summary><strong><code>root</code></strong>: <em>Defines the observation area.</em></summary><br />
943
- <ul>
944
- <strong>Type:</strong> Element | null<br />
945
- <br />
946
- <strong>Default:</strong> null (window)<br />
947
- <br />
948
- <strong>Description:</strong> <em><br />
949
- Specifies the element that serves as the bounding box for the intersection observation.
950
- If provided, it must be an ancestor of the observed element.<br />
951
- <br />
952
- If set to <code>null</code> (default), the window is used as the observation area.</em><br />
953
- <br />
954
- <strong>Example:</strong>
955
-
956
- ```tsx
957
- <IntersectionTracker root={document.getElementById("root")}>
958
- {children}
959
- </IntersectionTracker>
960
- ```
961
-
962
- </ul>
963
-
964
- </details>
965
-
966
- <h2></h2>
967
-
968
- <details>
969
- <summary><strong><code>rootMargin</code></strong>: <em>Sets the margin around the root element.</em></summary><br />
970
- <ul>
971
- <strong>Type:</strong> number | number[]<br />
972
- <br />
973
- <strong>Description:</strong> <em><br />
974
- Defines an offset around the root element, expanding or shrinking the observed area.<br />
975
- <br />
976
- Accepts a single number or an array for fine-tuned control:<br />
938
+ <div>
939
+
940
+ <details>
941
+ <summary><strong><code>children</code></strong>: <em>Custom user content.</em></summary><br />
977
942
  <ul>
978
- <li>A <strong>single number</strong> sets the same margin on all sides.</li>
979
- <li>A <strong>two-value array</strong> <code>[topBottom, leftRight]</code> applies margins vertically and horizontally.</li>
980
- <li>A <strong>four-value array</strong> <code>[top, right, bottom, left]</code> allows full control over each side.</li>
943
+ <strong>Type:</strong> React.ReactNode<br />
944
+ <br />
945
+ <strong>Example:</strong>
946
+
947
+ ```tsx
948
+ <IntersectionTracker>{children}</IntersectionTracker>
949
+ ```
950
+
981
951
  </ul>
982
- <br />
983
- Margins are converted to <code>px</code> values internally.</em><br />
984
- <br />
985
- <strong>Example:</strong>
986
-
987
- ```tsx
988
- <IntersectionTracker
989
- rootMargin={10}
990
- // rootMargin={[10, 20]}
991
- // rootMargin={[10, 20, 10, 20]}
992
- >
993
- {children}
994
- </IntersectionTracker>
995
- ```
996
-
997
- </ul>
998
-
999
- </details>
1000
-
1001
- <h2></h2>
1002
-
1003
- <details>
1004
- <summary><strong><code>threshold</code></strong>: <em>Defines when the callback is triggered.</em></summary><br />
1005
- <ul>
1006
- <strong>Type:</strong> number | number[]<br />
1007
- <br />
1008
- <strong>Description:</strong> <em><br />
1009
- .Specifies at what percentage of the observed element’s visibility the callback should be executed.<br />
1010
- <br />
952
+
953
+ </details>
954
+
955
+ <h2></h2>
956
+
957
+ <details>
958
+ <summary><strong><code>style</code></strong>: <em>Applies inline styles to the container.</em></summary><br />
1011
959
  <ul>
1012
- <li>A <strong>single number</strong> (e.g., <code>0.5</code>) triggers when that fraction of the element is visible.</li>
1013
- <li>A <strong>array of numbers</strong> (e.g., <code>[0, 0.5, 1]</code>) triggers the callback multiple times at different visibility levels.</li>
960
+ <strong>Type:</strong> React.CSSProperties<br />
961
+ <br />
962
+ <strong>Example:</strong>
963
+
964
+ ```tsx
965
+ <IntersectionTracker style={{ backgroundColor: "blue" }}>
966
+ {children}
967
+ </IntersectionTracker>
968
+ ```
969
+
970
+ </ul>
971
+
972
+ </details>
973
+
974
+ <h2></h2>
975
+
976
+ <details>
977
+ <summary><strong><code>root</code></strong>: <em>Defines the observation area.</em></summary><br />
978
+ <ul>
979
+ <strong>Type:</strong> Element | null<br />
980
+ <br />
981
+ <strong>Default:</strong> null (window)<br />
982
+ <br />
983
+ <strong>Description:</strong> <em><br />
984
+ Specifies the element that serves as the bounding box for the intersection observation.
985
+ If provided, it must be an ancestor of the observed element.<br />
986
+ <br />
987
+ If set to <code>null</code> (default), the window is used as the observation area.</em><br />
988
+ <br />
989
+ <strong>Example:</strong>
990
+
991
+ ```tsx
992
+ <IntersectionTracker root={document.getElementById("root")}>
993
+ {children}
994
+ </IntersectionTracker>
995
+ ```
996
+
997
+ </ul>
998
+
999
+ </details>
1000
+
1001
+ <h2></h2>
1002
+
1003
+ <details>
1004
+ <summary><strong><code>rootMargin</code></strong>: <em>Sets the margin around the root element.</em></summary><br />
1005
+ <ul>
1006
+ <strong>Type:</strong> number | number[]<br />
1007
+ <br />
1008
+ <strong>Description:</strong> <em><br />
1009
+ Defines an offset around the root element, expanding or shrinking the observed area.<br />
1010
+ <br />
1011
+ Accepts a single number or an array for fine-tuned control:<br />
1012
+ <ul>
1013
+ <li>A <strong>single number</strong> sets the same margin on all sides.</li>
1014
+ <li>A <strong>two-value array</strong> <code>[topBottom, leftRight]</code> applies margins vertically and horizontally.</li>
1015
+ <li>A <strong>four-value array</strong> <code>[top, right, bottom, left]</code> allows full control over each side.</li>
1016
+ </ul>
1017
+ <br />
1018
+ Margins are converted to <code>px</code> values internally.</em><br />
1019
+ <br />
1020
+ <strong>Example:</strong>
1021
+
1022
+ ```tsx
1023
+ <IntersectionTracker
1024
+ rootMargin={10}
1025
+ // rootMargin={[10, 20]}
1026
+ // rootMargin={[10, 20, 10, 20]}
1027
+ >
1028
+ {children}
1029
+ </IntersectionTracker>
1030
+ ```
1031
+
1032
+ </ul>
1033
+
1034
+ </details>
1035
+
1036
+ <h2></h2>
1037
+
1038
+ <details>
1039
+ <summary><strong><code>threshold</code></strong>: <em>Defines when the callback is triggered.</em></summary><br />
1040
+ <ul>
1041
+ <strong>Type:</strong> number | number[]<br />
1042
+ <br />
1043
+ <strong>Description:</strong> <em><br />
1044
+ .Specifies at what percentage of the observed element’s visibility the callback should be executed.<br />
1045
+ <br />
1046
+ <ul>
1047
+ <li>A <strong>single number</strong> (e.g., <code>0.5</code>) triggers when that fraction of the element is visible.</li>
1048
+ <li>A <strong>array of numbers</strong> (e.g., <code>[0, 0.5, 1]</code>) triggers the callback multiple times at different visibility levels.</li>
1049
+ </ul>
1050
+ <br />
1051
+ 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.</em><br />
1052
+ <br />
1053
+ <strong>Example:</strong>
1054
+
1055
+ ```tsx
1056
+ <IntersectionTracker
1057
+ threshold={0.5}
1058
+ // threshold={[0, 0.5, 1]}
1059
+ >
1060
+ {children}
1061
+ </IntersectionTracker>
1062
+ ```
1063
+
1064
+ </ul>
1065
+
1066
+ </details>
1067
+
1068
+ <h2></h2>
1069
+
1070
+ <details>
1071
+ <summary><strong><code>visibleContent</code></strong>: <em>Makes all elements always visible.</em></summary><br />
1072
+ <ul>
1073
+ <strong>Type:</strong> boolean<br />
1074
+ <br />
1075
+ <strong>Default:</strong> false<br />
1076
+ <br />
1077
+ <strong>Description:</strong> <em><br />
1078
+ If set to `true`, the tracked elements will always be visible, regardless of their actual intersection status.
1079
+ <br />
1080
+ This can be useful for testing purposes or when using the <code>onVisible</code> callback, ensuring it continues to trigger whenever the element enters the viewport.</em><br />
1081
+ <br />
1082
+ <strong>Example:</strong>
1083
+
1084
+ ```tsx
1085
+ <IntersectionTracker visibleContent>{children}</IntersectionTracker>
1086
+ ```
1087
+
1088
+ </ul>
1089
+
1090
+ </details>
1091
+
1092
+ <h2></h2>
1093
+
1094
+ <details>
1095
+ <summary><strong><code>onVisible</code></strong>: <em>Callback function triggered when the element becomes visible.</em></summary><br />
1096
+ <ul>
1097
+ <strong>Type:</strong> (key: string) => void<br />
1098
+ <br />
1099
+ <strong>Description:</strong> <em><br />
1100
+ A callback function that is invoked when the observed element enters the viewport or the defined observation area.<br />
1101
+ <br />
1102
+ The callback receives the <code>key</code> of the first child element as a parameter.<br />
1103
+ This can be useful for lazy loading, analytics tracking, animations, or any other action that needs to be triggered when an element becomes visible.<br />
1104
+ <br />
1105
+ ⚠ Note:<br />
1106
+ Instead of checking if <code>key</code> equals the element’s key name, use <code>includes</code> for verification. React may modify key names by prefixing them with special characters like <code>.$</code>, making direct equality checks unreliable and more expensive 💵.</em><br />
1107
+ <br />
1108
+ <strong>Example:</strong>
1109
+
1110
+ ```tsx
1111
+ <IntersectionTracker
1112
+ onVisible={(key) => {
1113
+ if (key.includes("elementId")) {
1114
+ // do something
1115
+ }
1116
+ }}
1117
+ >
1118
+ {children}
1119
+ </IntersectionTracker>
1120
+ ```
1121
+
1014
1122
  </ul>
1015
- <br />
1016
- 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.</em><br />
1017
- <br />
1018
- <strong>Example:</strong>
1019
-
1020
- ```tsx
1021
- <IntersectionTracker
1022
- threshold={0.5}
1023
- // threshold={[0, 0.5, 1]}
1024
- >
1025
- {children}
1026
- </IntersectionTracker>
1027
- ```
1028
-
1029
- </ul>
1030
-
1031
- </details>
1032
-
1033
- <h2></h2>
1034
-
1035
- <details>
1036
- <summary><strong><code>visibleContent</code></strong>: <em>Makes all elements always visible.</em></summary><br />
1037
- <ul>
1038
- <strong>Type:</strong> boolean<br />
1039
- <br />
1040
- <strong>Default:</strong> false<br />
1041
- <br />
1042
- <strong>Description:</strong> <em><br />
1043
- If set to `true`, the tracked elements will always be visible, regardless of their actual intersection status.
1044
- <br />
1045
- This can be useful for testing purposes or when using the <code>onVisible</code> callback, ensuring it continues to trigger whenever the element enters the viewport.</em><br />
1046
- <br />
1047
- <strong>Example:</strong>
1048
-
1049
- ```tsx
1050
- <IntersectionTracker visibleContent>{children}</IntersectionTracker>
1051
- ```
1052
-
1053
- </ul>
1054
-
1055
- </details>
1056
-
1057
- <h2></h2>
1058
-
1059
- <details>
1060
- <summary><strong><code>onVisible</code></strong>: <em>Callback function triggered when the element becomes visible.</em></summary><br />
1061
- <ul>
1062
- <strong>Type:</strong> (key: string) => void<br />
1063
- <br />
1064
- <strong>Description:</strong> <em><br />
1065
- A callback function that is invoked when the observed element enters the viewport or the defined observation area.<br />
1066
- <br />
1067
- The callback receives the <code>key</code> of the first child element as a parameter.<br />
1068
- This can be useful for lazy loading, analytics tracking, animations, or any other action that needs to be triggered when an element becomes visible.<br />
1069
- <br />
1070
- ⚠ Note:<br />
1071
- Instead of checking if <code>key</code> equals the element’s key name, use <code>includes</code> for verification. React may modify key names by prefixing them with special characters like <code>.$</code>, making direct equality checks unreliable and more expensive 💵.</em><br />
1072
- <br />
1073
- <strong>Example:</strong>
1074
-
1075
- ```tsx
1076
- <IntersectionTracker
1077
- onVisible={(key) => {
1078
- if (key.includes("elementId")) {
1079
- // do something
1080
- }
1081
- }}
1082
- >
1083
- {children}
1084
- </IntersectionTracker>
1085
- ```
1086
1123
 
1087
- </ul>
1124
+ </details>
1088
1125
 
1089
- </details>
1126
+ <h2></h2>
1090
1127
 
1091
- <h2></h2>
1128
+ </div>
1092
1129
 
1093
1130
  - ### Link:
1094
1131