繁体   English   中英

如何识别使用raphael.js创建的对象?

[英]How to identify an object created with raphael.js?

我正在使用raphel库创建带有图像的svg。 我需要到达对象并更改图像。 我可以使用数组索引来获取它,但是我想使用对象ID。

var R = Raphael("drawing","300", "300"),
c = [ { id:"obj1",obj: R.image("https://cdn3.iconfinder.com/data/icons/free-3d-glossy-interface-icon-set/64/Options.png", 0, 0, 50, 50)} ,
     {id:"obj2",obj: R.image("https://cdn3.iconfinder.com/data/icons/free-3d-glossy-interface-icon-set/64/Options.png", 100, 100, 50, 50)} ] ;
 move = function(dx,dy){
 this.attr({x: this.ox + dx, y: this.oy + dy});
},
start = function(){
this.ox = this.attr("x");
this.oy = this.attr("y");
this.animate({r: 70, opacity: .25}, 500, ">");
},
 up =function(){
this.animate({r: 50, opacity: 1}, 500, ">");
};

R.set(c).drag(move,start,up);

c[0].obj.attr("src","https://cdn3.iconfinder.com/data/icons/free-3d-glossy-interface-icon-set/64/Circulation.png")
c[0].node.setAttribute("id", "id_name");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM