You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,7 @@ This options let you modify the behavior of the animations, is an object that us
296
296
297
297
### Anchor property
298
298
299
-
It accepts 3 possible values as strings:"top", "middle" and "bottom". This refers to the edge of where the hook should make the calculations.
299
+
It accepts 3 possible values as strings:"top", "middle" and "bottom". This refers to the edge of where the hook should make the calculations.The default value is "middle"
300
300
301
301
For example:
302
302
@@ -308,7 +308,7 @@ For example:
308
308
309
309
### Delay property
310
310
311
-
It accepts a number, that should be between 0 and 100, it refers to percentage. If you pass values that are out of range it will be clamped to 0 or 100.
311
+
It accepts a number, that should be between 0 and 100, it refers to percentage. If you pass values that are out of range it will be clamped to 0 or 100. The default value is 0.
312
312
313
313
This means that, if you pass 50 the animation will delay to the 50%of the height of the component or viewport (depends on the anchor you use and the height of your component).
314
314
@@ -319,7 +319,7 @@ The animation won't start until the center of the screen (middle anchor) is at 3
319
319
320
320
### Duration property
321
321
322
-
It accepts a number, that should be between 0 and 100, it refers to percentage. If you pass values that are out of range it will be clamped to 0 or 100.
322
+
It accepts a number, that should be between 0 and 100, it refers to percentage. If you pass values that are out of range it will be clamped to 0 or 100. The default value is 100.
323
323
324
324
This means that, if you pass 50 the animation will last long to the 50%of the total distance it should execute.
325
325
@@ -334,6 +334,36 @@ The animation won't start until the center of the screen (middle anchor) is at t
334
334
If you struggle trying to understand that. I mean it could be hard to understand with all those numbers and calculations.
335
335
336
336
I recommend to experiment with those values. Just go and mess around with it, maybe you'll understand it better if you see how it behaves.
337
+
338
+
### Example
339
+
340
+
```js
341
+
342
+
//This is how this object looks. All values are optional. You can skip everyone of them
343
+
const options = {
344
+
anchor: "middle", // This is skippable because anchor is middle by default
345
+
delay: 30,
346
+
duration: 75,
347
+
};
348
+
349
+
//So now you just need to set it at the hooks
350
+
const color = useDynamicColor({
351
+
startColor: [67, 206, 162],
352
+
endColor: [24, 90, 157],
353
+
elementRef: ref, //Remember this is a ref to an HTML Element
354
+
options, // You can pass it like this because it has the same name as the property
355
+
});
356
+
357
+
//It's call height because I'm using this hook to change the height of a component on scroll
358
+
//In this case, the height will vary from 10 to 100
359
+
const height = useLinearValue({
360
+
startValue: 10,
361
+
endValue: 100,
362
+
elementRef: ref, //Remember this is a ref to an HTML Element
363
+
options: options, //You can pass it like this if the name is different.
0 commit comments