calebjacob / tooltipster

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

Using an array for "options.distance" prevents the position of the tooltip to be correct #802

Closed mcarlier-r7 closed 4 years ago

mcarlier-r7 commented 4 years ago

Hello,

First of all, thank you for your hard work on this plugin.

It seems that there is an issue with the calculation of the tooltip's position when the options.distance is an array.

Please take a look at those examples: https://jsfiddle.net/muhfv5gq/1/. If the options.distance is an array of 4 items, or if it's an array of 3 or fewer items and any option is updated using .option(), the position of the tooltip is not calculated correctly.

It looks like it's related to this logic: https://github.com/iamceege/tooltipster/blob/f818f589de54165209756aa3319f49f841d708a2/src/js/plugins/tooltipster/sideTip/tooltipster-sideTip.js#L185-L197 If self.__options.distance has a length of 4, it doesn't get assigned to an object with the correct properties.

Thank you for looking into it!

gavin310 commented 4 years ago

I actually just had this same issue. It seems to work correctly if you define distance as an object like: distance: { top: 20, bottom: 20, left: -40, right: -110 }.

louisameline commented 4 years ago

Thank you very much for your comments and for identifying the bad line. It should be fixed now in v4.2.8. Have a nice day!