问题
Surprisingly, I can't find an answer to this question in Stack Overflow. Seems no one has a need for what I'm specifically after. However, Skrollr has no real documentation I can find, so there's really no way of finding out how exactly this plugin works; unless, of course, one takes apart the code and investigates.
The following (what you'll see in the jsFiddle project linked below) is what I have. But what I want is to create a loop here so as not to have to include data-X
tags ad infinitum in my code. The idea is that this Skrollr script must work on a page that will be as long as the content, which is retrieved from MySQL. So it could be 1,000px long in one instante, for example, and then 50,000px long, as it were.
In such cases, I don't want to have to worry about Skrollr. I just want the animation to go on for ever as the user scrolls the window.
Any ideas? I've tried to build a couple of jQuery workarounds, but I can't get to the bottom of how the Skrollr.js script is doing what it does, so I can't 'fix it.' To make things worse, and adding to the Skrollr Mystery, the full skrollr.js
and the skrollr.min.js
do not work the same! Actually, it seems the full version, for some strange reason, is not working properly, whereas the 'minified' version of Skrollr works fine. The normal skrollr.js
(a) doesn't work in jsFiddle at all and (b) when I try it out in my localhost, it goes through the items once and then stops... Anyway, this just adds to the frustration, but is not the key issue. [ EDIT: Apparently, this is not a general issue. @Prinzhorn, who created the Skrollr plugin, was kind enough to look into my jsFiddle and says (as you can read in the comments) that the full .js is working for him. ]
HERE YOU HAVE THE JSFIDDLE PROJECT WITH ALL THAT NEEDS TO BE KNOWN!
Basically, as I said above, the idea is to have the one, two, three, four, five, four, three, two, one... constantly iterating up and down, up and down, while the user scrolls the window.
CONCLUSION
I'm keeping this as unanswered a while longer to see if we can come up with an answer on the "modulus operator" issue opened as another possibility due to the fact that Skrollr is not designed for the specific purpose for which I need it. However, I'm working on something else that could possibly work together with Skrollr. So I'm opening a new topic HERE if you want to check it out.
回答1:
Perhaps not the answer I was expecting, but it certainly sets me on the right track! @Prinzhorn, creator of the Skrollr plugin, says: "That's nothing skrollr is designed for. Just listen for scroll and do some simple math on the current scroll position (hint: use the modulo operator)."
So that's that. I'm basically just copying his answer. So thanks a bunch for your help, @Prinzhorn!
来源:https://stackoverflow.com/questions/17006436/skrollr-js-looping-action-that-will-happen-all-the-time-while-user-is-scrolling