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');
但是這也行不通。想法?