Last active
December 11, 2023 06:53
Revisions
-
giventofly revised this gist
Jul 11, 2018 . 1 changed file with 9 additions and 7 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 @@ -20,10 +20,12 @@ document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' }); //jQuery way with fast example: $('a.menu_items-link').on('click', function(e) { e.preventDefault(); const value = this.getAttribute('href'); //console.log(value); $('html, body').animate({ scrollTop: $('#'+value).offset().top }, 800, callback); }); -
giventofly revised this gist
Jul 11, 2018 . 1 changed file with 8 additions and 0 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 @@ -18,4 +18,12 @@ window.scrollBy({ // Scroll to a certain element document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' }); //jQuery way $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function(){ // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); -
giventofly created this gist
Jul 4, 2018 .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,21 @@ //from https://css-tricks.com/snippets/jquery/smooth-scrolling/ // 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' });