Created
December 7, 2018 03:38
-
-
Save NickDeckerDevs/31c78fcd7132f8e2a5a932fbc7b48f46 to your computer and use it in GitHub Desktop.
Scroll to the bottom of the hero div after clicking on an item [STICKY header]
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 characters
| // <header> | |
| // <div class="logo">......</div> | |
| // </header> | |
| // | |
| // <div id="hero"> | |
| // <span class="scroll-to-bottom-of-hero">Click here to scroll to bottom of hero</span> | |
| // </div> | |
| // #hero is the ID of the hero element | |
| // header is the header element that is sticky | |
| $('.find-out-how-link').on('click', function() { | |
| var heroHeight = $('#hero').outerHeight(); | |
| var navHeight = $('header').outerHeight(); | |
| $('html, body').animate({ | |
| scrollTop: (heroHeight - navHeight) + 'px' | |
| }, 'slow'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment