如何使链接的jquery动画在彼此之间流动?
查看此网站:
http://photoshop.tutorialcraft.com/
注意太阳到达顶部并然后向右。这是我的代码:
var windowWidth = $(window).width();
var width50 = (windowWidth*0.50)-220; //220 is half the width of the BG image being animated.
var width100 = (windowWidth*1);
$("#sunnmooncycle").css("backgroundPosition", "-440px 100px");.delay(2000)
.animate({'backgroundPosition':'('+ width50+'px '+'-400px' + ')'}, {duration:1500})
.animate({'backgroundPosition':'('+ width100+'px '+'100px' + ')'}, {duration:1500});
如果它可以采用更多的拱形模式,而不是两个直接的动画,那就太好了。如果我在其间创建 2 个“关键帧”,在拱形所在的位置,就会出现断断续续的情况,因为 Jquery 简化了动画,而不是仅仅从一个动画流到另一个动画。
我的数学能力不够好,无法弄清楚如何做到这一点,但由于窗口的宽度是在执行之前计算的,我确信有人可能知道如何做到这一点。
那么我如何让它以拱形而不是点对点的方式制作动画呢?
Check out this site:
http://photoshop.tutorialcraft.com/
Notice the sun go to the top and then to the right. Here is my code:
var windowWidth = $(window).width();
var width50 = (windowWidth*0.50)-220; //220 is half the width of the BG image being animated.
var width100 = (windowWidth*1);
$("#sunnmooncycle").css("backgroundPosition", "-440px 100px");.delay(2000)
.animate({'backgroundPosition':'('+ width50+'px '+'-400px' + ')'}, {duration:1500})
.animate({'backgroundPosition':'('+ width100+'px '+'100px' + ')'}, {duration:1500});
It would be nice if it could go in a more arching pattern, rather then two straight animations. If I create 2 "keyframes" in between, in the position where an arch would be, appears choppy, since Jquery eases animations, instead of just flowing from one to another.
I'm not good enough with math to figure out how I would do this, but since the width of the window is calculated just before execution, I'm sure someone may know how to do this.
So how do I get this to animate in an arch instead of point-to-point ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 jQuery 的
animate
的文档。您可以通过使用值 Linear 作为调用的第三个参数来指定关闭缓动。您可以通过这种方式设置任意数量的关键帧。
Take a look at the docs for jQuery's
animate
. You can simply specify the easing to be off by using the valuelinear
as the third argument to the call.You can set up as many keyframes as you want this way.