jQuery平滑动画 [英] JQuery smooth animation

查看:79
本文介绍了jQuery平滑动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个动画,使屏幕上的节拍"按钮变了.效果很好,这是一件事,动画太锐利"而不平滑,我该如何平滑呢?

I have this animation that makes some buttons on screen 'beat'. It works fine exept one thing, the animation is too 'sharp' and not smooth, how can I smooth it?

function myFunction() {
    setInterval(function () {
        tstFnc();
    }, 1000);
}

var flag = true;

function tstFnc() {
    var numM = Math.floor((Math.random() * 10) + 1);
    var stringM = '#mgf_main' + numM + ' img';

    $(stringM).animate({
        width: '80px',
        height: '80px'
    }, 150, function () {
        $(stringM).animate({
            width: '68px',
            height: '68px'
        }, 150, function () {
            // nothing
        });
    });
};

推荐答案

您可以在动画选项上设置easing属性.

You can set the easing property on the animate options.

http://api.jquery.com/animate/

http://easings.net/

这篇关于jQuery平滑动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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