Skip to content
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

Tooltip positioning algorithm does not always pick the best position #265

Open
wkrick opened this issue Oct 6, 2016 · 1 comment
Open

Comments

@wkrick
Copy link

wkrick commented Oct 6, 2016

Here's a test page with an image map and some tooltips that are displayed when clicking on hotspots:

http://files.3feetunder.com/mold/index.html

Notice that the location that ImageMapster picks for the bedroom closet, shower, and kitchen wall tooltips are not optimal. Some of them actually go off the page when there's plenty of room to display them next to the hotspot. At first, I thought it was a problem with the height of the tooltips, but there are other tooltips that are just as tall, if not taller that are positioned fine.

EDIT: Looking at the source code, it appears that the algorithm only considers six positions. It seems to me that it should consider at least 8 and then pick the one that puts the center of the tooltip closest to the center of the image...

starting at the upper left corner of the hotspot and going clockwise...

upper left corner of hotspot at upper right corner of tooltip
upper left corner of hotspot at lower left corner of tooltip
upper right corner of hotspot at lower right corner of tooltip
upper right corner of hotspot at upper left corner of tooltip
lower right corner of hotspot at lower left corner of tooltip
lower right corner of hotspot at upper right corner of tooltip
lower left corner of hotspot at upper left corner of tooltip
lower left corner of hotspot at lower right corner of tooltip

Another possibly simpler approach might be to connect the center of the image with the center of the hotspot area with an imaginary straight line and place the tooltip based on where the line intersects the hotspot boundary. This will naturally try to place the tooltip toward the center of the image whenever possible.

@techfg
Copy link
Collaborator

techfg commented Jan 30, 2021

Hello @wkrick -

Thank you for your suggestion, apologies for the replayed reply!

Agreed that IM could do a much better job of positioning tooltips. We'd gladly accept a PR if you'd like to contribute to improve this functionality!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants