Skip to content

Should be possible to pass refs into helper functions #551

Closed
@ccampbell

Description

@ccampbell

I tried to find an existing ticket for this, but I couldn’t. I think someone might have brought it up on the gitter chat at some point.

I am looking for a way to reference an element directly in a helper function. This is a somewhat crude example of what I am looking for:

https://svelte.technology/repl?version=1.18.2&gist=0ae4439ea03245395f61c94a1b67cefd

If there is already a way to do feel free to close this ticket.


My use case is I have a dynamic tooltip-like component that I want to dynamically position, but I want to offset the left position by half of the width of the element (the width is dynamic). I can pretty easily achieve this using window.getComputedStyle(document.querySelector('.tooltip')) or something like that, but would be nice to be able to reference the element directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions