-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share/Reuse tooltips #64
Comments
Assuming we had a single tooltip element for multiple targets, we run into an unfortunate limitation of the positioning library, Popper.js. Popper.js only supports a single target reference on creation, and does not allow that reference to be changed. We theoretically could create a bunch of disabled Popper.js instances, and only call update on them when we hover over a given target... though that would probably require a significant rewrite of ember-popper, or perhaps a specialized component for that use-case. Will continue thinking on this. It's definitely possible, but the underlying libs aren't geared toward this use-case (yet 😉 ) |
Thanks for the insights. It's not an issue right now, to have all the "duplicate" tooltips, as i don't see a performance impact yet. So consider this as low priority. |
@kybishop You can use a fake DOM object as reference element in Popper.js and make it proxy the info of the desired real DOM element. |
#75 does a good job at mitigating this issue, but a truly reusable tooltip would be the holy grail. I'd like to have this implemented at some point, so keeping this open for now. |
Event delegation is something I'm currently trying to implement in tippy.js https://jsfiddle.net/fc1vkvo5/ It only uses a single popper instance and tooltip, so it's O(1) to init and really fast. The only downside I've witnessed is that because there can't be two poppers on the page, it will forcibly remove the popper when transitioning out to update the new position if another target was reached. There's no need to use a fake DOM obj, just update the reference of in the popperInstance to the new event target. |
@atomiks thanks for the ping! I've been watching your PR to see how it goes. |
Would be nice, to have a way to reuse/share tooltips.
Simplified use case example of a list with several items, each with a delete icon button having a "Delete" tooltip:
At the moment, this would create a distinct tooltip for each item. Ends up having a lot of "duplicate" tooltip elements.
If there would be a way to declare a tooltip beforehand and then just bind it to several elements, one could eliminate a lot of these "duplicate" tooltip elements.
The text was updated successfully, but these errors were encountered: