calebjacob / tooltipster

A jQuery tooltip plugin
MIT License
2.76k stars 482 forks source link

Allow setting of arbitrary viewport on initialization #800

Open locomo opened 4 years ago

locomo commented 4 years ago

Along the lines of this issue: #758

I'm wondering if it is currently possible (or if not, could it be a possible enhancement) to setup viewport position/dimensions when tooltipster gets initialized?

I understand that we can do this with functionPosition .. but this is fairly complex. It would be nice to just be able to specify either an element or specific dimensions during initialization and then just let tooltipster continue to do the heavy lifting of calculating tooltip position as normal.

My use case is that I need the tooltips to appear in side of a canvas element that is zoomable/draggable within my website layout.

thanks!

louisameline commented 4 years ago

Hello there! Thank you for your message. This is feasible and should be made with the help of a plugin, because this is not a mainstream use case. A plugin gets the proposed position in input, an may return a different position in output. So you'd want to write a plugin that would have an "arbitrary viewport" parameter, and that would make sure that the position returned is always within this viewport. You can see how existing plugins were made, it's not hard. If you write the plugin, we'll mention it in the documentation! Thank you

locomo commented 4 years ago

ok sounds good .. i'll take a stab at this

would you suggest i base my code on the '__reposition' function as a starting point for calculating position within the viewport?