Skrollr.js:在用户滚动窗口时将一直发生的循环动作 [英] Skrollr.js: Looping action that will happen all the time while user is scrolling window

查看:99
本文介绍了Skrollr.js:在用户滚动窗口时将一直发生的循环动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

令人惊讶的是,我在Stack Overflow中找不到该问题的答案.似乎没有人需要我特别想要的东西.但是,Skrollr没有我可以找到的真实文档,因此,实际上没有办法找出此插件的工作原理.除非,当然,除非有人拆开代码并进行调查.

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.

以下是我所拥有的(您将在下面链接的jsFiddle项目中看到).但是我想要在这里创建一个循环,以便不必在我的代码中包含data-X标记 ad infinitum .这个想法是,该Skrollr脚本必须在与内容(从MySQL检索到的内容)一样长的页面上工作.因此,例如,在一个实例中它的长度可能是1,000px,然后又是50,000px.

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.

在这种情况下,我不必担心Skrollr.我只希望动画在用户滚动窗口时一直持续下去.

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.

有什么想法吗?我试图构建一些jQuery解决方法,但是我无法深入了解Skrollr.js脚本如何执行其工作,因此无法对其进行修复".更糟的是,添加到Skrollr之谜的skrollr.jsskrollr.min.js完全不同!实际上,出于某些奇怪的原因,完整版似乎无法正常工作,而Skrollr的缩小版"可以正常工作.普通skrollr.js(a)在jsFiddle 中完全不起作用,而(b)当我在本地主机中尝试时,它会遍历所有项然后停止...无论如何,这只会增加挫败感,但不是关键问题.

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. [ 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. ]

在这里您拥有JSFIDDLE项目,并且需要知道所有这些!

HERE YOU HAVE THE JSFIDDLE PROJECT WITH ALL THAT NEEDS TO BE KNOWN!

基本上,就像我在上面说的那样,我们的想法是让 1、2、3、4、5、4、3、2、1 ... 不断地上下迭代向下滚动,同时用户滚动窗口.

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.

我将其保留为 unanswer 一段时间,以查看我们是否可以针对模量运算符"问题提出答案,这是由于Skrollr的设计不合理而引起的另一种可能性针对我需要的特定目的.但是,我正在研究可能与Skrollr一起使用的其他东西.因此,我打开了一个新主题 HERE (如果要签出).

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.

推荐答案

也许不是我所期望的答案,但这肯定使我走上了正轨! Skrollr插件的创建者@Prinzhorn说:这不是skrollr设计的目的.只听滚动并在当前滚动位置做一些简单的数学运算(提示:使用模运算符)."

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)."

就是这样.我基本上只是复制他的答案.因此,感谢您的帮助,@ Prinzhorn!

So that's that. I'm basically just copying his answer. So thanks a bunch for your help, @Prinzhorn!

这篇关于Skrollr.js:在用户滚动窗口时将一直发生的循环动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆