什么是“步骤”? jquery 中的对象
我无法理解以下代码
$(this).animate({rotate3Di: Degrees}, options)
。这里rotate3Di
是 不是用于动画的 CSS 属性。$.fx.step.rotate3Di = function(){}
。在这里,他们添加了一个方法 调用rotate3Di
到step
。什么是step
、fx
。我确信 当我们向$.fn
添加一个方法时,我们将能够访问该方法 在jquery的结果集中。但是通过在step
中添加一个方法,哪里可以 我们访问它吗?
I'm unable to understand the following codes
$(this).animate({rotate3Di: degrees}, options)
. Hererotate3Di
is
not a css property to animate.$.fx.step.rotate3Di = function(){}
. Here, they are adding a method
calledrotate3Di
tostep
. What isstep
,fx
. I'm sure that
when we add a method to$.fn
we will be able to access that method
in jquery's result set. But by adding a method tostep
, where can
we access it?
Got this plugin from http://www.zachstronaut.com/projects/rotate3di/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$.fx.step
是一个对象,其中包含通过一次迭代递增动画的函数。动画在 jQuery 中的工作方式(大致)是
$.animate()
方法在元素上调用并设置间隔/超时。然后,每次超时/间隔触发时,jQuery 都会循环遍历传递给.animate()
的对象中的每个属性,如果$. 则调用默认增量函数(仅稍微更改该 css 属性)。 fx.step[propertyName]
不存在。但是,如果$.fx.step[propertyName]
确实存在,那么该函数就会被调用。您可以访问方法
$.fx.step。直接旋转3Di()(尽管它所做的一切没有意义,假设您传递了预期的参数,只是执行一次非动画旋转)。它不是传统意义上的 jQuery 插件,因此您无法调用
$(selector).rotate3di()
。$.fx.step
is an object containing functions that increment the animation by one iteration.The way animation works in jQuery (roughly) is the
$.animate()
method is called on an element and sets up an interval/timeout. Then each time the timeout/interval fires jQuery cycles through each property in the object passed to.animate()
, calling the default incrementation function (which just alters that css property slightly) if$.fx.step[propertyName]
doesn't exist. But if$.fx.step[propertyName]
does exist then that function gets called instead.You can access the method
$.fx.step.rotate3Di()
directly (although it doesn't make sense to as all it would do, assuming that you pass in the expected parameters, is carry out a single non-animated rotation). It's not a jQuery plugin in the conventional sense, so you can't call$(selector).rotate3di()
.