3 ms·
This is very cool. I've been wanting an alternative for Raphael in projects that don't require old IE support because of some compromises Raphael does in order
by duopixel 14y ago
This is very cool. I've been wanting an alternative for Raphael in projects that don't require old IE support because of some compromises Raphael does in order to support VML.
I am a bit worried that I can't find a way of changing multiple elements at once, in d3 for example I'd do...
d3.selectAll("rect").attr("fill", "red");
In Raphael I'd do...
var set = paper.set(//insert rects here);
set.attr({"fill": "red});
But in Bonsai I'd do...
var set = [//insert rects here];
set.forEach(function(el){
el.fill("red");
})
So it doesn't abstract the iteration for you.
- Skywing 14y agoPersonally, I never did like things abstracting the iteration for me. In Javascript, I tend to favor explicit loops over huge chains of method calls, or visually confusing abstracting like the Raphael example. Just looking at that Raphael example, I'd have to actually think about the code to understand what it does right off the bat (shocker, I know, but I think you get my point). I actually think that the Bonsai example there is the most straight forward and flexible. Of course, this is all just opinion.
- duopixel 14y agoWhen working with DOM elements (SVG elements are also part of the DOM) it get messy pretty quickly. Think of it as syntactic sugar, because you can always opt for using standard arrays instead of using Raphael sets... var rects = [//insert rects here] rects.forEach(function(rect){ rect.attr({fill: "red"}); })
- deleted 14y ago[deleted]