morphing-scroll 1.5.22 → 2.1.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.
@@ -0,0 +1,437 @@
1
+ type MorphScrollT = {
2
+ // General Settings
3
+ /**---
4
+ * Custom class name.
5
+ * ___
6
+ * @example
7
+ * ```tsx
8
+ * <MorphScroll {...props}
9
+ * className="custom-class"
10
+ * >
11
+ * {children}
12
+ * </MorphScroll>
13
+ * ```
14
+ * */
15
+ className?: string;
16
+ /**---
17
+ * Custom user content.
18
+ * ___
19
+ * @example
20
+ * ```tsx
21
+ * <MorphScroll {...props} >
22
+ * {children}
23
+ * </MorphScroll>
24
+ * ```
25
+ * */
26
+ children?: React.ReactNode;
27
+
28
+ // Scroll Settings
29
+ /**---
30
+ * Type of progress element.
31
+ * ___
32
+ * @default "scroll"
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * <MorphScroll {...props}
37
+ * type="slider"
38
+ * >
39
+ * {children}
40
+ * </MorphScroll>
41
+ * ```
42
+ */
43
+ type?: "scroll" | "slider" | "sliderMenu";
44
+ /**---
45
+ * Scrolling direction.
46
+ * ___
47
+ * @default "y"
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <MorphScroll {...props}
52
+ * direction="x"
53
+ * >
54
+ * {children}
55
+ * </MorphScroll>
56
+ * ```
57
+ */
58
+ direction?: "x" | "y" | "hybrid";
59
+ /**---
60
+ * Scroll position value and additional options.
61
+ * ___
62
+ * @default { duration: 200; updater: false }
63
+ *
64
+ * @description
65
+ * - `value`: *Scroll position value*
66
+ * - `duration`: *Duration of the scroll animation*
67
+ * - `updater`: *Helper to force an update when setting the same scroll value repeatedly*
68
+ *
69
+ * @note
70
+ * `value` property can be an array of two values for hybrid directions
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * <MorphScroll {...props}
75
+ * scrollPosition={{ value: 100, duration: 300 }}
76
+ * >
77
+ * {children}
78
+ * </MorphScroll>
79
+ * ```
80
+ */
81
+ scrollPosition?: {
82
+ value: number | "end" | (number | "end")[];
83
+ duration?: number;
84
+ updater?: boolean;
85
+ };
86
+ /**---
87
+ * Callback for scroll value.
88
+ * ___
89
+ * @description
90
+ * - `left`: *Current scroll position on the x-axis*
91
+ * - `top`: *Current scroll position on the y-axis*
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * <MorphScroll {...props}
96
+ * onScrollValue={(left, top) => console.log("Scroll position:", left, top)}
97
+ * >
98
+ * {children}
99
+ * </MorphScroll>
100
+ * ```
101
+ */
102
+ onScrollValue?: (left: number, top: number) => void;
103
+ /**---
104
+ * Callback for scroll status.
105
+ * ___
106
+ * @example
107
+ * ```tsx
108
+ * <MorphScroll {...props}
109
+ * isScrolling={(motion) => console.log(motion)}
110
+ * >
111
+ * {children}
112
+ * </MorphScroll>
113
+ * ```
114
+ */
115
+ isScrolling?: (motion: boolean) => void;
116
+
117
+ // Visual Settings
118
+ /**---
119
+ * `[width, height]` dimension of `MorphScroll`.
120
+ *
121
+ * **REQUIRED**
122
+ * ___
123
+ * @description
124
+ * - `number` *sets the width and height, can be an array of 2 numbers*
125
+ * - `"auto"` *for automatic resizing based on the parent element*
126
+ *
127
+ * @example
128
+ * ```tsx
129
+ * <MorphScroll {...props}
130
+ * size={[200, 100]}
131
+ * >
132
+ * {children}
133
+ * </MorphScroll>
134
+ * ```
135
+ */
136
+ size: number | number[] | "auto";
137
+ /**---
138
+ * [width, height] dimension of cells for each object.
139
+ * ___
140
+ * @default [width, height] from size
141
+ *
142
+ * @description
143
+ * - `number` *sets the width and height, can be an array of 2 numbers*
144
+ * - `"size"` *all objects will take the dimensions from the `size` prop*
145
+ * - `"firstChild"` *all objects will have the same size as the first child*
146
+ * - `"none"` *objects will be created without defined size*
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * <MorphScroll {...props}
151
+ * objectsSize={80}
152
+ * >
153
+ * {children}
154
+ * </MorphScroll>
155
+ * ```
156
+ */
157
+ objectsSize:
158
+ | number
159
+ | "size"
160
+ | "firstChild"
161
+ | "none"
162
+ | (number | "size" | "firstChild" | "none")[];
163
+ /**---
164
+ * Number of cells in each direction.
165
+ *___
166
+ * @example
167
+ * ```tsx
168
+ * <MorphScroll {...props}
169
+ * crossCount={3}
170
+ * >
171
+ * {children}
172
+ * </MorphScroll>
173
+ * ```
174
+ */
175
+ crossCount?: number;
176
+ /**---
177
+ * Gap between cells.
178
+ * ___
179
+ * @note
180
+ * *It can be 1 number or an array of 2 or 4 numbers*
181
+ *
182
+ * @example
183
+ * ```tsx
184
+ * <MorphScroll {...props}
185
+ * gap={10}
186
+ * >
187
+ * {children}
188
+ * </MorphScroll>
189
+ * ```
190
+ */
191
+ gap?: number | number[];
192
+ /**---
193
+ * Margin for the* `.ms-objects-wrapper`.
194
+ * ___
195
+ * @note
196
+ * *It can be 1 number or an array of 2 or 4 numbers*
197
+ *
198
+ * @example
199
+ * ```tsx
200
+ * <MorphScroll {...props}
201
+ * wrapperMargin={10}
202
+ * >
203
+ * {children}
204
+ * </MorphScroll>
205
+ * ```
206
+ */
207
+ wrapperMargin?: number | number[];
208
+ /**---
209
+ * Minimum height or width of the `.ms-objects-wrapper`.
210
+ * ___
211
+ * @description
212
+ * - `number` *sets the min-size*
213
+ * - `"full"` *min-size is equal to property `size`*
214
+ *
215
+ * @note
216
+ * - *Can be used as 1 value, or an array of 2 values for [width, height].*
217
+ *
218
+ * @example
219
+ * ```tsx
220
+ * <MorphScroll {...props}
221
+ * wrapperMinSize={"full"}
222
+ * >
223
+ * {children}
224
+ * </MorphScroll>
225
+ * ```
226
+ */
227
+ wrapperMinSize?: number | "full" | (number | "full")[];
228
+ /**---
229
+ * [horizontal, vertical] aligns your content when it is smaller than the `size`.
230
+ *___
231
+ * @note
232
+ * *Use 1 value to align one or both axes, or an array of 2 values to align both axes*
233
+ *
234
+ * @example
235
+ * ```tsx
236
+ * <MorphScroll {...props}
237
+ * wrapperAlign={["start", "center"]}
238
+ * >
239
+ * {children}
240
+ * </MorphScroll>
241
+ * ```
242
+ */
243
+ wrapperAlign?: "start" | "center" | "end" | ("start" | "center" | "end")[];
244
+ /**---
245
+ * Aligns the objects inside `MorphScroll`.
246
+ * ___
247
+ * @example
248
+ * ```tsx
249
+ * <MorphScroll {...props}
250
+ * elementsAlign={"center"}
251
+ * >
252
+ * {children}
253
+ * </MorphScroll>
254
+ * ```
255
+ */
256
+ elementsAlign?: "start" | "center" | "end";
257
+ /**---
258
+ * Direction of the provided elements.
259
+ * ___
260
+ * @default "row"
261
+ *
262
+ * @example
263
+ * ```tsx
264
+ * <MorphScroll {...props}
265
+ * elementsDirection={"column"}
266
+ * >
267
+ * {children}
268
+ * </MorphScroll>
269
+ * ```
270
+ */
271
+ elementsDirection?: "row" | "column";
272
+ /**---
273
+ * Gradient overlay at the edges of the scroll area.
274
+ * ___
275
+ * @default { size: 40 }
276
+ *
277
+ * @example
278
+ * ```tsx
279
+ * <MorphScroll {...props}
280
+ * edgeGradient={{ color: "rgba(0,0,0,0.4)"}}
281
+ * >
282
+ * {children}
283
+ * </MorphScroll>
284
+ * ```
285
+ */
286
+ edgeGradient?: boolean | { color?: string; size?: number };
287
+
288
+ // Progress Bar
289
+ /**---
290
+ * Triggers for the scroll progress.
291
+ * ___
292
+ * @description
293
+ * - `wheel`: *Triggered by mouse wheel scroll*
294
+ * - `content`: *Triggered by content click and drag*
295
+ * - `progressElement`: *Triggered by provided progress element*
296
+ * - `arrows`: *Triggered by arrow button click*
297
+ *
298
+ * @note
299
+ * - *`progressElement` can be thumb or slider, use props `type`*
300
+ * - *If `progressElement` is true and `type` is "scroll", the default browser scroll element will be used*
301
+ * - *`arrows` can be designed with their className or you can provide a custom element*
302
+ *
303
+ * @example
304
+ * ```tsx
305
+ * <MorphScroll {...props}
306
+ * progressTrigger={ wheel: true, progressElement: <ScrollThumb /> }
307
+ * >
308
+ * {children}
309
+ * </MorphScroll>
310
+ * ```
311
+ */
312
+ progressTrigger: {
313
+ wheel?: boolean;
314
+ content?: boolean;
315
+ progressElement?: boolean | React.ReactNode;
316
+ arrows?: boolean | { size?: number; element?: React.ReactNode };
317
+ };
318
+ /**---
319
+ * Reverse the progress bar position.
320
+ * ___
321
+ * @default false
322
+ *
323
+ * @note
324
+ * *Use 1 boolean or an array of 2 booleans to set different values for hybrid `direction`*
325
+ *
326
+ * @example
327
+ * ```tsx
328
+ * <MorphScroll {...props}
329
+ * progressReverse={true}
330
+ * >
331
+ * {children}
332
+ * </MorphScroll>
333
+ * ```
334
+ */
335
+ progressReverse?: boolean | boolean[];
336
+ /**---
337
+ * Hover visibility of the progress bar.
338
+ * ___
339
+ * @default false
340
+ *
341
+ * @example
342
+ * ```tsx
343
+ * <MorphScroll {...props}
344
+ * progressVisibility={"hover"}
345
+ * >
346
+ * {children}
347
+ * </MorphScroll>
348
+ * ```
349
+ */
350
+ scrollBarOnHover?: boolean;
351
+
352
+ // Optimization
353
+ /**---
354
+ * Rendering strategy for performance optimization.
355
+ * ___
356
+ * @description
357
+ * - `"lazy"`: *Does not deleted content when it leaves the viewport*
358
+ * - `"virtual"`: *Deletes content when it leaves the viewport*
359
+ * - `rootMargin`: *Distance for loading from the root element*
360
+ * - `stopLoadOnScroll`: *Stops loading content when scrolling*
361
+ *
362
+ * @note
363
+ * *`render` is not compatible with `objectsSize: "none"`*
364
+ *
365
+ * @example
366
+ * ```tsx
367
+ * <MorphScroll {...props}
368
+ * render={{ type: "virtual" }}
369
+ * >
370
+ * {children}
371
+ * </MorphScroll>
372
+ * ```
373
+ */
374
+ render?: {
375
+ type: "lazy" | "virtual";
376
+ rootMargin?: number | number[];
377
+ stopLoadOnScroll?: boolean;
378
+ };
379
+ /**---
380
+ * Handling of empty scroll elements.
381
+ * ___
382
+ * @description
383
+ * - `"clear"`: *Removes empty elements from the DOM*
384
+ * - `fallback`: *Replaces empty elements with a fallback element*
385
+ * - `clickTrigger`: *Start clearing elements when passed selector is clicked*
386
+ *
387
+ * @example
388
+ * ```tsx
389
+ * <MorphScroll {...props}
390
+ * emptyElements={{
391
+ * mode: "clear",
392
+ * clickTrigger: { selector: ".close-button" }
393
+ * }}
394
+ * >
395
+ * {children}
396
+ * </MorphScroll>
397
+ * ```
398
+ */
399
+ emptyElements?: {
400
+ mode: "clear" | "fallback" | { fallback: React.ReactNode };
401
+ clickTrigger?: { selector: string; delay?: number };
402
+ };
403
+ /**---
404
+ * Enables React Suspense for children.
405
+ * ___
406
+ * @example
407
+ * ```tsx
408
+ * <MorphScroll {...props}
409
+ * suspending
410
+ * >
411
+ * {children}
412
+ * </MorphScroll>
413
+ * ```
414
+ */
415
+ suspending?: boolean;
416
+ /**---
417
+ * Fallback element to display during loading or placeholder.
418
+ * ___
419
+ * @note
420
+ * *Used when:*
421
+ * - *`suspending === true`*
422
+ * - *`render.stopLoadOnScroll === true`*
423
+ * - *`emptyElements.mode === "fallback"`*
424
+ *
425
+ * @example
426
+ * ```tsx
427
+ * <MorphScroll {...props}
428
+ * fallback={<div>Loading...</div>}
429
+ * >
430
+ * {children}
431
+ * </MorphScroll>
432
+ * ```
433
+ */
434
+ fallback?: React.ReactNode;
435
+ };
436
+
437
+ export default MorphScrollT;
@@ -0,0 +1,77 @@
1
+ type ResizeTrackerT = {
2
+ /**---
3
+ * Custom class name.
4
+ * ___
5
+ * @example
6
+ * ```tsx
7
+ * <ResizeTracker
8
+ * className="custom-class"
9
+ * >
10
+ * {children}
11
+ * </ResizeTracker>
12
+ * ```
13
+ */
14
+ className?: string;
15
+ /**---
16
+ * Custom user content.
17
+ * ___
18
+ * @example
19
+ * ```tsx
20
+ * <ResizeTracker>
21
+ * {children}
22
+ * </ResizeTracker>
23
+ * ```
24
+ * */
25
+ children: React.ReactNode;
26
+ /**---
27
+ * Custom inline styles.
28
+ * ___
29
+ * @example
30
+ * ```tsx
31
+ * <ResizeTracker
32
+ * style={{ backgroundColor: "yellow" }}
33
+ * >
34
+ * {children}
35
+ * </ResizeTracker>
36
+ * ```
37
+ */
38
+ style?: React.CSSProperties;
39
+ /**---
40
+ * Defines size measurement behavior.
41
+ * ___
42
+ * @description
43
+ * - `inner`: *Fits content*
44
+ * - `outer`: *Fills parent*
45
+ * - `all`: *Combines both*
46
+ *
47
+ * @default "inner"
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <ResizeTracker
52
+ * measure="outer"
53
+ * >
54
+ * {children}
55
+ * </ResizeTracker>
56
+ * ```
57
+ */
58
+ measure?: "inner" | "outer" | "all";
59
+ /**---
60
+ * Callback on dimension change.
61
+ * ___
62
+ * @description
63
+ * *`rect` is the dimensions of the container*
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * <ResizeTracker
68
+ * onResize={(rect) => console.log(rect)}
69
+ * >
70
+ * {children}
71
+ * </ResizeTracker>
72
+ * ```
73
+ */
74
+ onResize?: (rect: Partial<DOMRectReadOnly>) => void;
75
+ };
76
+
77
+ export default ResizeTrackerT;