Skip to content
Snippets Groups Projects
Commit 32d58cdf authored by Daniel Kurowski's avatar Daniel Kurowski
Browse files

Changed API call from SmoothScroll to SmoothScroll.enable()

parent a80088ff
No related branches found
No related tags found
1 merge request!7Improve structure
Pipeline #26884 passed
......@@ -18,10 +18,10 @@ yarn add @grifart/smoothscroll
import SmoothScroll from '@grifart/smoothscroll';
// use defaults
SmoothScroll();
SmoothScroll.enable();
// customize
SmoothScroll({
SmoothScroll.enable({
scrollOnLoad: false,
scrollOnLinkClick: true,
});
......
......@@ -7,7 +7,7 @@
<script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5/velocity.min.js"></script>
<script src="dist/index.js" type="text/javascript"></script>
<script>
SmoothScroll({
SmoothScroll.enable({
scrollOnLoad: true,
scrollOnLinkClick: true,
});
......
......@@ -8,16 +8,22 @@ export interface SmoothScrollOptions {
readonly scrollOnLinkClick?: boolean;
}
function SmoothScroll(options?: SmoothScrollOptions): void
/**
* Wrapped into class for intuitive API use – `SmoothScroll.enable()`
*/
class SmoothScroll
{
setupVelocity(Velocity);
public static enable(options?: SmoothScrollOptions): void
{
setupVelocity(Velocity);
if ( ! (options && options.scrollOnLoad === false)) {
initializeOnLoadScroll();
}
if ( ! (options && options.scrollOnLoad === false)) {
initializeOnLoadScroll();
}
if ( ! (options && options.scrollOnLinkClick === false)) {
initializeOnLinkClickScroll();
if ( ! (options && options.scrollOnLinkClick === false)) {
initializeOnLinkClickScroll();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment