From 32d58cdf31f5ea2839e97efdbd87ab0e23b9d56d Mon Sep 17 00:00:00 2001
From: Daniel Kurowski <daniel.kurowski@grifart.cz>
Date: Fri, 29 May 2020 16:05:14 +0200
Subject: [PATCH] Changed API call from SmoothScroll to SmoothScroll.enable()

---
 README.md    |  4 ++--
 demo.html    |  2 +-
 src/index.ts | 20 +++++++++++++-------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index dc64b32..0fbdd16 100644
--- a/README.md
+++ b/README.md
@@ -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,
 });
diff --git a/demo.html b/demo.html
index c18f2c4..d1f1655 100644
--- a/demo.html
+++ b/demo.html
@@ -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,
 		});
diff --git a/src/index.ts b/src/index.ts
index 9f776a5..367a6d3 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -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();
+		}
 	}
 }
 
-- 
GitLab