Last active
August 11, 2017 06:42
-
-
Save andreasvirkus/d9e09ee119a00b4e1b5957c6e5d7939d to your computer and use it in GitHub Desktop.
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
/** | |
* VueRouter's scrollBehavior for scrolling to anchor links | |
* | |
* TODO: Swap TweenLite maybe for my custom jump.s snippet or jump.js lib (10kB vs 0.4kB vs 1.3kB) | |
* https://github.com/callmecavs/jump.js | |
*/ | |
export default new Router({ | |
mode: 'history', | |
scrollBehavior(to, from, savedPosition) { | |
if (to.hash) { | |
TweenLite.to(window, 1, {scrollTo: to.hash, offsetY: 200}); | |
// return { | |
// selector: to.hash, | |
// offset: { x: 0, y: 200 }, | |
// }; | |
} else { | |
console.log('not hash'); | |
return { x: 0, y: 0 }; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment