jQuery Slider 只工作两次?
我在整个过程中使用 .animate 函数用 jQuery 制作了自己的滑块,当我使用它一次和两次时,滑块可以工作,但在第三次尝试时,它变得疯狂!基本上它类似于 Microsoft 的“家庭版”和“工作版”滑块,但复杂程度要低得多(现在)
它位于网站上,为了向您展示我的意思,以下是 URL: http://glorbi.com/index3
(点击“工作”,然后“家庭”,然后“工作”,它开始失败)
这是处理滑动的 jQuery:
$("#sidebar2").click(function(){
$("#innerSec2").animate({"right" : 130}, 1000);
$("#sidebar2").animate({"height" : 1100});
$("#innerSec").animate({"left" : -840}, 1000);
$("#innerSec").animate({"left" : 840}, 200);
$("#sidebar").animate({"height" : 400});
});
$("#sidebar").click(function(){
$("#innerSec").animate({"left" : 0}, 1000);
$("#sidebar").animate({"height" : 1100});
$("#innerSec2").animate({"right" : 970}, 1000);
$("#innerSec2").animate({"left" : 710}, 200);
$("#sidebar2").animate({"height" : 400});
});
我尝试过使用回调,但它们会导致更连续的反应,部分移动滑块,这看起来非常可怕。
我还知道滑动时的 z-index 问题,我会解决这个问题!
有谁知道我该如何解决这个问题?该代码非常通用,并且每个操作都有严格的值,我真的不明白它是如何失败的。 :S
非常感谢!非常感谢任何帮助! :)
I've made my own slider with jQuery using .animate functions throughout, and the slider works when I use it once, and twice, but on the 3rd try, it goes crazy! Basically it's similar to Microsoft's 'For Home' and 'For Work' slider, but a lot less complex (right now)
It is live on a website, and to show you what I mean, here's the URL:
http://glorbi.com/index3
(Click For Work, then For Home, then For work, it starts to fail)
Here's the jQuery that handles the sliding:
$("#sidebar2").click(function(){
$("#innerSec2").animate({"right" : 130}, 1000);
$("#sidebar2").animate({"height" : 1100});
$("#innerSec").animate({"left" : -840}, 1000);
$("#innerSec").animate({"left" : 840}, 200);
$("#sidebar").animate({"height" : 400});
});
$("#sidebar").click(function(){
$("#innerSec").animate({"left" : 0}, 1000);
$("#sidebar").animate({"height" : 1100});
$("#innerSec2").animate({"right" : 970}, 1000);
$("#innerSec2").animate({"left" : 710}, 200);
$("#sidebar2").animate({"height" : 400});
});
I've tried using callbacks, but they lead to a more sequential reaction, moving the slider in parts, which looks pretty horrible.
Also I am aware of the z-index issue as it slides, and I'll fix that!
Does anyone know how I could fix this? The code is pretty generic, and it's strict values for every action, I don't really see how it's failing. :S
Thanks alot! Any help is greatly appreciated! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在firebug中摆弄它之后,我发现在我们点击
sidebar2
div后,innerSec2
上的left:710px
引起了问题,所以我尝试了以下操作,除了您可以修复的z order
问题之外,它似乎有效:DAfter fiddling with it in firebug, I found out that the
left:710px
oninnerSec2
is causing problem, after we click onsidebar2
div, so I tried following and it seems working exceptz order
problem which you can fix :D