我尝试创建一组Raphael对象,并在单击窗口(例如)时为它们设置动画。
这样可行:http://jsfiddle.net/6YdrG/2/
$(function() {
(function () {
var R = Raphael($('#svg')[0]);
var i, circles = circlenumber = R.set();
var v = [{offset: 0, circleVal: '+ 29 %'}, {offset: 120, circleVal: '+ 90 %'}, {offset: 240, circleVal: '+ 107 %'}, {offset: 360, circleVal: '+ 20 %'}];
for (i = 0; i <= 3; i++) {
circles[i] = R.circle(29+v[i].offset, 29, 10).attr({fill: '#000', stroke: 'none'});
//circlenumber[i] = R.text(29+v[i].offset, 29, v[i].circleVal).attr({font: '12px JauresSemibold, serif', fill: '#fff'});
};
$(window).click(function() {
console.log('click');
for (i = 0; i <= 3; i++) {
circles[i].animate(Raphael.animation({r: 28}, 800, 'easeInOut').delay(100*(i)));
};
});
})();
});
但是如果删除“//”来添加circlenumber [i]元素,它就不再有用了......
想法?谢谢!