jQuery的缓解作用 - 变量的COM prehension [英] jQuery easing function — variables' comprehension

查看:183
本文介绍了jQuery的缓解作用 - 变量的COM prehension的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何jQuery的缓动功能工作?举个例子:

How does the easing function for jQuery work? Take for example:

easeInQuad = function (x, t, b, c, d) {
    return c*(t/=d)*t + b;
};

这是如何工作的?什么是每个参数持有?我将如何实施动画一些愚蠢的宽松?

How does that work? What does each parameter hold? How would I implement some dumb easing for an animation?

此外,我怎么会附加一个宽松格局的jQuery,被加载到$ .easing不够好?

Also how would I attach an easing pattern to jQuery, is loading it into $.easing good enough?

推荐答案

据对jQuery 1.6.2源的缓动函数的含义如下。该函数在时间上在动画过程中调用的不同点。在瞬间的叫法,

According to the jQuery 1.6.2 source, the meaning of the easing function is as follows. The function is called at various points in time during the animation. At the instants it is called,


    X和T都表示,现在是什么时候了,相对于动画的开始。 x是pssed在区间[0,1],其中0为开始,1月底浮点数前$ P $。 t是因为动画开始以毫秒为单位pssed前$ P $。
  • d是动画的持续时间,如动画调用中指定,以毫秒为单位。
  • B = 0和c = 1。
  • x and t both say what the time is now, relative to the start of the animation. x is expressed as a floating point number in the range [0,1], where 0 is the start and 1 is the end. t is expressed in milliseconds since the start of the animation.
  • d is the duration of the animation, as specified in the animate call, in milliseconds.
  • b=0 and c=1.

的缓动函数应在区间[0,1]返回一个浮点数,称之为研究。 jQuery的然后计算 X =开始+ R *(最终开始),其中启动结束是在调用动画指定的属性的开始和结束的值,它设置属性值 X

The easing function should return a floating point number in the range [0,1], call it r. jQuery then computes x=start+r*(end-start), where start and end are the start and end values of the property as specified in the call to animate, and it sets the property value to x.

据我所看到的,jQuery的不给你当被称为动画步功能,只让你说:如果我叫在时间t的话,我应该是迄今为止在整个过直接控制动画。因此,你不能,例如,问你的对象更频繁,有时当它移动速度重绘。另外,我不知道为什么别人说的b是起始值和c是变化的 - 这不是jQuery的源$ C ​​$ C说:

As far as I can see, jQuery doesn't give you direct control over when the animation step function is called, it only lets you say "if I am called at time t, then I should be thus far through the entire animation." Therefore you cannot, for example, ask for your object to be redrawn more frequently at times when it is moving faster. Also, I don't know why other people say b is the start value and c is the change -- that's not what jQuery source code says.

如果你想定义自己的缓动函数做同样的easeInQuad,例如,

If you wanted to define your own easing function to do the same as easeInQuad, for example,

$.extend(jQuery.easing,{myfunc:function(x,t,b,c,d) { return x*x; }})

$('#marker').animate({left:'800px'},'slow','myfunc');

这篇关于jQuery的缓解作用 - 变量的COM prehension的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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