Skip to content

Commit aa7dcee

Browse files
authored
Merge pull request #41 from zJaaal/dev
added more examples
2 parents 3604b21 + 7e2a554 commit aa7dcee

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ This options let you modify the behavior of the animations, is an object that us
296296

297297
### Anchor property
298298

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"
300300

301301
For example:
302302

@@ -308,7 +308,7 @@ For example:
308308

309309
### Delay property
310310

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.
312312

313313
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).
314314

@@ -319,7 +319,7 @@ The animation won't start until the center of the screen (middle anchor) is at 3
319319

320320
### Duration property
321321

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.
323323

324324
This means that, if you pass 50 the animation will last long to the 50% of the total distance it should execute.
325325

@@ -334,6 +334,36 @@ The animation won't start until the center of the screen (middle anchor) is at t
334334
If you struggle trying to understand that. I mean it could be hard to understand with all those numbers and calculations.
335335

336336
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.
364+
});
365+
366+
```
337367
338368
339369
## Circle Component

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-scroll-utilities",
33
"private": false,
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"license": "MIT",
66
"type": "module",
77
"main": "src/lib/index.ts",

0 commit comments

Comments
 (0)