Skip to content

[Suggestion] Make Component Work With SVG #62

@krowark

Description

@krowark

Hi,
I've been trying to make this component work with SVGs and found a series of small changes to the package that would help. Of course, I could fork this repository, make my changes there, and use that but I figured I'd note my findings here in case supporting SVG is a direction the core team wants to consider.

The main roadblocks for getting SVG to work with this component are twofold.

  1. Currently the "doObjectsCollide" method only correctly handles HTMLElements despite the function being easily generalize-able to Elements, which includes SVGElements, with some minor tweaks. Those tweaks include changing "doObjectsCollide" to expect and check for instances of Elements, as well as changing "getBoundsForNode" to the below:
    image
    This change is needed because SVG doesn't support node.offsetWidth/node.offsetHeight anymore.

  2. Like the repo already allows for the component tag to be modified from "div", selectable items will need a way to change the tag of the enclosing element. This should be a reasonably simple change, as the extra "component" attribute can follow the same pattern as "selectableKey" does.

Perhaps this added functionality has already been thought of and dismissed as out of scope, though I cannot imagine why. Let me know what you think.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions