Last active
October 6, 2016 12:58
-
-
Save apsolut/0ce01b9bbab02e10a161d99abbfec2cc to your computer and use it in GitHub Desktop.
onepage website with working url-s
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
| jQuery(document).ready(function () { | |
| var clickHandler = ('ontouchstart' in document.documentElement ? "touchstart" : "click"); | |
| jQuery("#menu-mainmenu li a:not(.ignore)").bind(clickHandler, function(e) { | |
| // link - substring will take only "#name" - and you can add link with "/#name" | |
| // so it can work on onepage site that have blog. | |
| var link = jQuery(this).attr('href').substring(jQuery(this).attr('href').indexOf('#')) | |
| // this will take link and calculate top offset | |
| var posi = jQuery(link).offset().top; | |
| // use GreenSock (GSAP) for animations - TweenLite | |
| // this will scroll window to posi location | |
| TweenLite.to(window, 1.5, {scrollTo: {y: posi -80}, ease: Power3.easeOut}); | |
| e.preventDefault(); | |
| }); | |
| }); //JQREADY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment