admin管理员组文章数量:1290955
In Raphael.js, If I have a path object, I would like to reset the attribute, how to do it?
myPath.attr('M', VALUE_FOR_M)
.attr('L', VALUE_FOR_L);
seems not working...
In Raphael.js, If I have a path object, I would like to reset the attribute, how to do it?
myPath.attr('M', VALUE_FOR_M)
.attr('L', VALUE_FOR_L);
seems not working...
Share Improve this question edited Apr 27, 2011 at 14:41 Joachim Sauer 308k59 gold badges566 silver badges622 bronze badges asked Apr 27, 2011 at 14:37 MellonMellon 38.9k78 gold badges192 silver badges265 bronze badges 4- 1 @Joachim, why shouldn't I think so???? Of course I know Raphael is not jQuery. Raphael also provide attr() method to set attribute for element. If you check Raphael documentation on its official website. raphaeljs./reference.html#attr – Mellon Commented Apr 27, 2011 at 15:00
-
However, reading the linked documentation shows that
M
orL
are not listed in the possible parameters. – Joachim Sauer Commented Apr 27, 2011 at 15:03 - 1 Yes, that's why I ask here how to set attribute for path, since there is no reference for that. – Mellon Commented Apr 27, 2011 at 15:05
-
1
as far as I understand
M
andL
are not atributes of a path, they are simply elements that can exist in its specification. They can also exist multiple times so "changing their value" doesn't really make a lot of sense. Could you post an example of what you're trying to achieve? – Joachim Sauer Commented Apr 27, 2011 at 15:06
2 Answers
Reset to default 6you do it like this:
var newPath = ["M", VALUE_FOR_M_X, VALUE_FOR_M_Y,
"L", VALUE_FOR_L_X, VALUE_FOR_L_Y];
myPath.attr({ path : newPath });
newPath is a pathString (see SVG path string format)
To create a path, I prefer,
var myPath = paper.path(['M', M_VAL0, M_VAL1,
'L', L_VAL0, L_VAL1].join(' '));
myPath.insertAfter(nodewhatever);
It makes your actions much easier to follow.
to update your path,
myPath.remove();
myPath = paper.path(['M', M_VAL2, M_VAL3,
'L', L_VAL2, L_VAL3].join(' '));
myPath.insertAfter(nodewhatever);
Is this what you wanted to do?
本文标签: javascriptRaphaeljs how to set attribute for a pathStack Overflow
版权声明:本文标题:javascript - Raphael.js how to set attribute for a path? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741519308a2383084.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论