I use https://github.com/Prinzhorn/skrollr to animate the background of my site while scrolling. However, I also want my links to scroll up and down the page, as a regular one-page site does.
The problem is that they work, if I manually scroll through the background changes, if I click the link, the page scrolls to the right place. The problem is that when I press the button, the background also does not scroll.
It seems that I work with two different scroll functions, and as a result, they do not work together, and I need to use the same one.
Here is the code.
js - Follow the link:
var $root = $('html, body'); $('a').click(function() { var href = $.attr(this, 'href'); $root.animate({ scrollTop: $(href).offset().top }, 500, function () { window.location.hash = href; }); return false; });
js - Skrollr init
skrollr.init({ smoothScrolling: true, forceHeight: true });
I will try to assemble the violin to make it more understandable, but hopefully the answer is really simple.
javascript jquery scroll parallax
Daimz
source share