问题描述
|
我已使用Jquery中的slideUp / Down函数为页面上的div设置动画,但是它在iPhone上运行不佳,因此我决定编写一个等效的Webkit来解决性能问题,但是您无法对jQuery .css应用回调或.addclass。
我有这个功能:
$(\'#collapse\').css(\'height\',\'0\');
但是我需要伪造一个回调,从而使这项工作有效:
$(\'#collapse\').css(\'height\',\'0\',function() {
//do something after
});
有人知道怎么做吗?
Webkit动画设置为1秒。
解决方法
只需使用
setTimeout
即可; jQuery无法告诉内置浏览器动画是否已完成:
$(\'#collapse\').css(\'height\',0);
setTimeout(function() {
// code will happen after the timeout has completed
},1000); // 1 second
这样做的缺点是您必须在两个位置设置动画的时间。
, 另一个可能性是syropia.net/journal/css3-transition-callbacks-in-jquery
= D