2012-01-12 39 views
0

我正在使用Raphael。下面是我想用动画旋转的俄罗斯方块的代码块:旋转不被识别为属性()属性

function ele(id) { 
     return document.getElementById(id); 
    } 

    window.onload = function() { 
     var paper = new Raphael(ele('canvas_container'), 500, 500); 

     var tetronimo = paper.path('M 250 250 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z') 
     tetronimo.attr({ 
      gradient: '90-#526c7a-#64a0c1', 
      stroke: '#3b4449', 
      'stroke-width':10, 
      'stroke-linejoin':'round', 
      rotation:-90, //**This is where the problem is** 
      title:'This is a tetris block' 
     }); 

     tetronimo.animate({ 
      rotation:360 //**This is where the problem is** 
     }, 2000, 'bounce'); 
    } 

此代码也可以在本教程中找到:http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/

没有比onload其它事件触发动画,但是当页面加载时没有执行动画。我也尝试使用Raphael的变换方法:

tetronimo.attr({ 
      gradient: '90-#526c7a-#64a0c1', 
      stroke: '#3b4449', 
      'stroke-width':10, 
      'stroke-linejoin':'round', 
      transform:'r90', 
      title:'This is a tetris block' 
     }); 
tetronimo.animate({ 
      transform:'r360' 
     }, 2000, 'bounce'); 

但是这也行不通。想法?

回答