jQuery动画的自定义值(不是CSS属性) [英] jQuery animate of custom value (not a CSS property)

查看:165
本文介绍了jQuery动画的自定义值(不是CSS属性)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做最奇怪的事情:使用animate更改值,而不是css属性,而只是一个变量。

I'd like to do the strangest thing: make a value change with animate which isn't a css property but just a variable.

我想在用户单击其边框时旋转元素。所以我需要动画的角度值,然后在自定义绘图算法使用它。

I need this because I want to rotated an element when an user clicks on its border. So I need to animate the angle value and then use it in a custom drawing algorithm.

我试图使用隐藏的DIV的css属性只是存储它的角度值和

I tried to use css property of an hidden DIV just to store it's angle value and animate it, but it doesn't work properly.

任何人都可以帮助我吗?

Can anyone helps me with it please?

推荐答案

在搜索同一件事时,偶然发现了这个问题,正确的答案似乎是

Just stumbled upon this while searching for the same thing and the correct answer appears to be

$({foo:0}).animate({foo:100}, {
    step: function(val) {
        // val takes values from 0 to 100 here
    }
})

http://james.padolsey.com/javascript/fun-with-jquerys-animate/

这篇关于jQuery动画的自定义值(不是CSS属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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