Scroll to link with skrollr

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.

+7
javascript jquery scroll parallax
source share
2 answers

If anyone else encounters this problem, they will answer it: https://github.com/Prinzhorn/skrollr-menu

This will allow you to scroll through the internal links along with the Skrollr animation. A HUGE plus and a very simple fix, you don’t even need any of your own scroll code, and it will work with you.

+9
source share

There is a way to do this, Skrollr has several methods that are very useful, in the console just enter a variable containing skrollr, it will show some methods that you can use, one of them is "setScrollTop (int, bool)", so just call this method with the necessary information, for example:

s.setScrollTop (9000, true)

This means that I want it to scroll to a height of 9000. It works great, you just need to know the position of the height at which you need to go.

+1
source share

All Articles