Last active
June 5, 2022 19:01
-
-
Save saboyadev/8a50bfed301d932ccf1e7fd4cb0fa684 to your computer and use it in GitHub Desktop.
Revisions
-
saboyadev revised this gist
Jun 5, 2022 . 1 changed file with 12 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,13 @@ // Smooth Scrolling $('.btn').on('click', function(e) { if (this.hash !== '') { e.preventDefault(); const hash = this.hash; $('html, body').animate( { scrollTop: $(hash).offset().top }, 800 ); } }); -
saboyadev created this gist
Jun 4, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // Scroll to specific values // scrollTo is the same window.scroll({ top: 2500, left: 0, behavior: 'smooth' }); // Scroll certain amounts from current position window.scrollBy({ top: 100, // could be negative value left: 0, behavior: 'smooth' }); // Scroll to a certain element document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' });