scroll();
Note: if you are using React you should wrap this function call like this.
if (typeof window !== "undefined") {
scroll();
}
-
target
- HTML element that's gonna have the smooth scroll applied to.
Default: <html>
.
- HTML element that's gonna have the smooth scroll applied to.
-
options
-
speed
- Determines the speed of the scroll.
Default: 100
. If used withoutsmooth
, the default is gonna be usedsmooth: 14
.
- Determines the speed of the scroll.
-
smooth
- Determines the smoothness of the scroll, the greater the value the slower the scroll will be.
-
mode
- Specifies the mode. Mode types are
'snail' | 'normal' | 'turbo'
. It overrides thespeed
and thesmooth
values if both or one of them is presented.
- Specifies the mode. Mode types are
-
smoothEdgeStop
- Determines whether or not to have a smooth stop at the edges of the screen ( top or bot ) or if you want it to be normal,
Default: false
which is thenormal
behavior.
- Determines whether or not to have a smooth stop at the edges of the screen ( top or bot ) or if you want it to be normal,
-
npm install silky-smooth-scroll
if you have faced any issues with it in React you can add the react-ts folder in your project like this:
curl "https://github.com/hossammenem/silky-smooth-scroll/tree/master/react-ts" -o "smoothScroll" # or call the out folder whatever you want
You can also use it in Windows Powershell since it's gonna call Invoke-WebRequest
by itself.
The main focus right now is to make it compatible with types so we don't need a whole ts version for it, and also to make it compatible with react.
Also, it hasn't been tested heavily on different browsers, so feel free to open an issue request if you have faced any issues with it in your browser.