动画方法无法在Chrome中运行

时间:2012-06-21 01:27:09

标签: javascript google-chrome animation raphael jquery-animate

function swap(fromTo, toFrom)
{
    var temp = blocks[fromTo];
    var templabel = BlockLabels[fromTo];

    blocks[fromTo].animate({ x: blocks[toFrom].X }, 1500, ">");
    BlockLabels[fromTo].animate({ x: BlockLabels[toFrom].X }, 1500, ">");

    blocks[toFrom].animate({ x: temp.X }, 1500, ">");
    BlockLabels[toFrom].animate({ x: templabel.X }, 1500, ">"); 
}

此交换功能适用于IE9但不适用于Chrome。我正在使用Raphael2.0

已更新:http://jsfiddle.net/ZgEty/ chrome和safari无法正常工作,但IE9确实

1 个答案:

答案 0 :(得分:1)

啊......这就是你访问x的方式,就像它是一个对象属性一样。试试这个:

blocks[fromTo].animate({ x: blocks[toFrom].attr( 'x' ) }, 1500, ">");
BlockLabels[fromTo].animate({ x: BlockLabels[toFrom].attr( 'x' ) }, 1500, ">");

blocks[toFrom].animate({ x: temp.attr( 'x' ) }, 1500, ">");
BlockLabels[toFrom].animate({ x: templabel.attr( 'x' ) }, 1500, ">");

我也forked your fiddle