开始的条件函数:Ariel Flesler 的 SerialScroll 中的设置
站点位于@beattrainsoundsystem.com/home
我正在使用serialScroll 为许多包含舞蹈角色的div 制作动画,并使用LocalScroll 为内容div 制作动画。我的问题是,当您尝试加载带有哈希值的 URL(例如beattrainsoundsystem.com/home#store)时,角色 div 不会动画到正确的位置。我知道要实现这一点,我需要为“start:”设置创建一个条件函数,以根据 URL 中的哈希值更改“start:”值。作为 jQuery 的新手,我不太确定如何编写此代码。
我已经在使用 URI 解析器插件来返回 URL 中的哈希值,因此对于“http:// www.beattrainsoundsystem.com/home#store”
var urlHash = $.url.attr('anchor');
将返回“store”
所以我需要的是一个函数,它说:
if (urlHash == home) {
var start = 0
} else if (urlHash == mixes) {
var start = 1,
} else if (urlHash == contact) {
var start = 2,
}
这显然没有正确编码,但它是我需要使此工作的脚本的概念化。
感谢您的帮助!
Site is Located @ beattrainsoundsystem.com/home
I'm using serialScroll to animate a number of divs containing dancing characters, and using LocalScroll to animate the content divs. My issue is that when you try and load a URL with a hash ( for example beattrainsoundsystem.com/home#store) the character divs do not animate to the correct position. I know that to make this happen, I need to create a conditional function for the "start:" setting, to change the "start:" value depending on the hash in the URL. As somewhat of a novice at jQuery, I'm not exactly sure how to code this.
I'm already using a URI parser plugin to return the hash in the URL, so for "http://www.beattrainsoundsystem.com/home#store"
var urlHash = $.url.attr('anchor');
will return "store"
So what I need is a function that says:
if (urlHash == home) {
var start = 0
} else if (urlHash == mixes) {
var start = 1,
} else if (urlHash == contact) {
var start = 2,
}
This is obviously not coded correctly, but is a conceptualization of the script that I need to make this work.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能应该将其与 localScroll 集成。如果调用$.localScroll.hash(),它将滚动到哈希指向的元素,并将更改通知serialScroll。
You should probably integrate this with localScroll. If you call $.localScroll.hash(), it will scroll to the element pointed by the hash and notify the change to serialScroll.
它并没有直接跳到我身上,我试图找到顶部链接的点击事件正在处理的地方,所以我可以给出一个具体的例子。
看起来动画不起作用的唯一一次是当我直接转到 URL 中包含哈希值的某个页面时。因此,我可能会这样做:
一个 id,例如
如果您希望它加载到正确的位置而不显示动画,那么这并不理想
您应该能够执行以下操作:
It doesn't jump right out at me where the click events for the links at the top are being handled which I was trying to find so I could give a specific example.
It looks like the only time the animation doesn't work is when I go directly to some page that has the hash in the URL. So, I might do something like:
<a href="#name">
an id such as<a id="name" href="#name">
This isn't ideal if you want it to load in the correct position without showing an animation.
You should be able to do something like this:
});
});