svgdotjs/svg.js

Feature request: `group(id)` constructor for SVG.G

jango-fx opened this issue · 5 comments

Feature request: group(id) constructor for SVG.G

to my mind a <g> tag's main attribute is its id (just like the width and height of a rect) and I would expect it to be set similarly intuitively during construction. Without a cumbersome additional call of .attr('id', 'ID').

so instead of

let theGroup = draw.group()
theGroup.attr('id', 'myGroupID')

simply

let theGroup = draw.group("myGroupID")

to get

<svg>
  <g id="myGroupID">
  </g>
</svg>

(love your lib though ❤️ )

The constructor always takes the dimensions of the object. Since g don't have dimensions itself they don't take an argument.

But you can always pass an object with attributes: canvas.group({ id })

arr, I still don't find that very intuitive, but I might bow to your consistency 😜

haha, and I thought intuity comes from consistency :D

The constructor always takes the dimensions of the object

not true for SVG.text() though 🤨

@jango-fx text doesnt have a dimension!! At least not until SVG 2 which isnt broadly supported and a whole other beast