diff --git a/README.md b/README.md
index 36c52b8..fe1bb16 100644
--- a/README.md
+++ b/README.md
@@ -16,27 +16,49 @@ yarn add react-spring-scroll-to-hook
## Usage
+useScrollTo hook accepts 1 argument a that is react-spring config: https://react-spring.io/common/configs
+scrollTo function returned from useScrollTo hook accepts 2 arguments:
+
+ 1: Element | string | number (number of pixels from top of the window)
+ 2: Number (offset in pixels from element you want to scroll to)
+
+I don't know how three shaking works but I would recommend using @react-spring/web (used in this hook) instead of react-spring
+
+## Examples
+
```tsx
import {config} from '@react-spring/web'
import useScrollTo from 'react-spring-scroll-to-hook'
+//Scroll to element
const BasicExampleWthConfig = () => {
- const {scrollTo} = useScrollTo(config.molasses)
- return (
-
- )
+ const {scrollTo} = useScrollTo(config.molasses)
+ return (
+
+ )
}
+//Scroll to top
const ScrollToTop = () => {
- const {scrollTo} = useScrollTo()
- return (
-
- )
+ const {scrollTo} = useScrollTo({ mass: 1, tension: 180, friction: 12 })
+ return (
+
+ )
+}
+
+//Scroll to top with offset and first argument as string only (document.querySelector is used in the hook)
+const ScrollToTopWithOffset = () => {
+ const {scrollTo} = useScrollTo()
+ return (
+
+ )
}
```
diff --git a/package.json b/package.json
index 82450c0..4e5bf21 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-spring-scroll-to-hook",
- "version": "1.0.2",
+ "version": "1.0.3",
"description": "Simple custom hook for ScrollTo functionality using react-spring v9+.",
"author": "TomasSestak",
"license": "MIT",