【问题标题】:animate method not working in Chrome动画方法在 Chrome 中不起作用
【发布时间】:2012-06-23 05:31:03
【问题描述】:
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 可以

【问题讨论】:

  • 您是否遇到任何错误?您能否提供一个重现问题的jsFiddle

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


【解决方案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

【讨论】:

  • 只是一点注释,如果你不写这样的变量名可能会更好。有点困惑
  • toFrom 和 fromTo,你的意思是?嗯,它们在交换操作的上下文中很有意义。
猜你喜欢
  • 2013-02-24
  • 2014-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多