Difference between revisions of "Template:Washington"
Line 276: | Line 276: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
− | + | // to top right away | |
− | + | if ( window.location.hash ) scroll(0,0); | |
− | + | // void some browsers issue | |
− | + | setTimeout( function() { scroll(0,0); }, 1); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | $(function() { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | } | + | // your current click function |
+ | $('.scroll').on('click', function(e) { | ||
+ | e.preventDefault(); | ||
+ | $('html, body').animate({ | ||
+ | scrollTop: $($(this).attr('href')).offset().top + 'px' | ||
+ | }, 1000, 'swing'); | ||
+ | }); | ||
− | + | // *only* if we have anchor on the url | |
+ | if(window.location.hash) { | ||
− | + | // smooth scroll to the anchor id | |
− | + | $('html, body').animate({ | |
− | + | scrollTop: $(window.location.hash).offset().top + 'px' | |
+ | }, 1000, 'swing'); | ||
+ | } | ||
− | + | }); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</script> | </script> |
Revision as of 23:21, 10 September 2015