-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Automatic placement of tooltips/popovers #1833
Comments
Does this work? Jacob wrote something for twipsy/popover but it doesn't seem to work in 2.0 |
this seams to work
|
don't think i'll be adding an option to teh plugins themselves. but if that works for you - it's meant to be extended like that :) |
Cool, thanks man. |
@quasiperfect Working like a charm with version 2.0.3. Thank you so much! |
quasiperfect's answer doesn't work in all cases because it does not take the size of the tooltip into account. So the position choosen will often be one which clips the popup to the viewports border. |
Not to pee in quasiperfect's cheerios, but it also doesn't work if your target element has a min-width. One would need to do this for height/width instead:
Still doesn't address width of tooltip... need to add:
Untested, typed-in code here... fyi |
I ran across this thread while looking to add auto placement for the popover tooltip today and wanted to share how this helped me. I added an if statement (based on quasiperfect's function) to the Tooltip prototype's show function right before the switch statement that sets the offset values (at line 148 of bootstrap-tooltip.js):
Now I just put this in the popover options:
Has worked for the first few tests. FYI, if you use this be aware It is not affected by how far down the user has scrolled and favors left and bottom placement over top placement (even if there is adequate space and more visible room at the top). Edit: Updated location of change from location in my bootstrap.js file to bootstrap-tooltip.js file. |
Nice, thanks 👍 Saved my day! |
Well now, all this back and forth and little mishaps and issues - this is exactly the reason why something like this should be part of the core; the devil is in the details. I'm all for light weight, but in this case, it's a little too light weight - having tooltips and popovers open outside of the browser window, where the user can't see them, simply isn't useful. If 5 lines of code will do the job, I'm not even sure light weight is really a meaningful argument. Please reconsider? |
PS: a better way to do this, would be to allow for alternative placements. For design reasons, your tooltips may have an ideal placement, and one or more alternative fall-back placements - for example, you may have a fixed sidebar on the right, so you know there will always be enough space for the tooltip on the right. Allowing multiple alternative positions, separated by spaces, in order of preference, such as: This behavior would also be backwards compatible, since specifying only one position with no alternatives would work the same as before. |
@quasiperfect: That work for me. thanks so much |
Here's what I'm doing atm.
and
The text was updated successfully, but these errors were encountered: