Created
May 30, 2018 18:04
-
-
Save yankiara/57d8046deaf7db6f44676596390b02fb to your computer and use it in GitHub Desktop.
JQuery scroll
This file contains 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 characters
// Scroll to top | |
jQuery('html, body').animate({ scrollTop: 0 }, 1000); | |
// Scroll to element | |
jQuery('html, body').animate({ scrollTop: jQuery('#element').offset().top }, 1000); | |
// Scroll and center element on screen | |
jQuery('html, body').animate({ scrollTop: jQuery('#element').offset().top - jQuery(window).height()/2 - 100 }, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment