From 7b4ecfb86063349b6d5272a722a3e0978f1c12de Mon Sep 17 00:00:00 2001
From: Daniel Kurowski <daniel.kurowski@grifart.cz>
Date: Mon, 8 Jun 2020 09:37:19 +0200
Subject: [PATCH] Added scrollTo*() methods to integration test

---
 src/integrationTest.html | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/integrationTest.html b/src/integrationTest.html
index 2939868..194bf29 100644
--- a/src/integrationTest.html
+++ b/src/integrationTest.html
@@ -11,11 +11,25 @@
 			scrollOnLoad: true,
 			scrollOnLinkClick: true,
 		});
+
+		document.addEventListener('DOMContentLoaded', () => {
+			document.getElementById('scrollToElement').addEventListener('click', (event) => {
+				event.preventDefault(); // prevent jump to top as there is `#` in `href` attribute
+				SmoothScroll.scrollToElement(document.getElementById('footer'));
+			});
+
+			document.getElementById('scrollToOffset').addEventListener('click', () =>
+				SmoothScroll.scrollToOffset(5000));
+
+			document.getElementById('scrollToTarget').addEventListener('click', () =>
+				SmoothScroll.scrollToTarget('#item3'));
+		});
 	</script>
 	<style type="text/css">
 		body {
 			margin: 0 auto;
 			max-width: 40rem;
+			padding-bottom: 150vh;
 		}
 
 		.goToTop {
@@ -34,7 +48,6 @@
 	</style>
 </head>
 <body>
-<!-- @todo: improve this file -->
 
 	<div id="nahoru"></div>
 	<a href="#item1">Item1</a>
@@ -42,6 +55,9 @@
 	<a href="#item3">Item3</a>
 	<a href="#item4">Item4</a>
 	<a href="#item5">Item5</a>
+	<a href="#" id="scrollToElement">Scroll to element</a>
+	<button type="button" id="scrollToOffset">Scroll to 5000px top offset</button>
+	<a href="#" id="scrollToTarget">Scroll to target</a>
 
 	<div>
 		<div id="item1">
@@ -222,5 +238,15 @@
 			Go to top
 		</a>
 	</div>
+
+	<div id="footer">
+		<p>
+			Footer
+		</p>
+
+		<p>
+			Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam ornare wisi eu metus. Pellentesque ipsum.
+		</p>
+	</div>
 </body>
 </html>
-- 
GitLab