这是为什么JQuery的动画心惊肉跳? [英] Why is this JQuery animation jumpy?

查看:174
本文介绍了这是为什么JQuery的动画心惊肉跳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图慢慢动画图像,但它的延迟之后只是突然跳跃,实际上没有滑过。任何想法,为什么?

  $(文件)。就绪(函数(){
    $('#图片)淡入(1000).delay(1500).animate({'顶':'25px的','左':'20像素','高度':'101px'},2000);
});


解决方案

尝试使用回调函数:

  $(文件)。就绪(函数(){
    $('#图片)。淡入(1000,函数(){
        $(本).delay(500).animate({'顶':'25px的','左':'20像素','高度':'101px'},2000);
    });
});

匿名函数后会淡入执行完毕。

UPD :否睡眠功能,更改为延迟。例如,在这里: http://jsfiddle.net/CbgzG/

UPD2 :OP的code的作品一样好:的http:// jsfiddle.net/CbgzG/1/

I am trying to animate an image slowly, but it's just jumping suddenly after the delay, not actually sliding over. Any idea why?

$(document).ready(function() {
    $('#Picture').fadeIn(1000).delay(1500).animate({'top': '25px', 'left': '20px', 'height': '101px'},2000);
});

解决方案

Try using callback function:

$(document).ready(function() {
    $('#Picture').fadeIn(1000, function(){
        $(this).delay(500).animate({'top': '25px', 'left': '20px', 'height': '101px'},2000);
    });
});

The anonymous function will be executed after fadeIn is complete.

UPD: No sleep function, changed to delay. Example here: http://jsfiddle.net/CbgzG/

UPD2: OP's code works just as well: http://jsfiddle.net/CbgzG/1/

这篇关于这是为什么JQuery的动画心惊肉跳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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