-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Auto positioning of tooltip #7996
Conversation
This patch changes the positioning of the tooltip when there is no room for the tooptip in the position it would normally show. As discussed here: #7399
placement = 'left' | ||
} else if (tpt.top > $(window).scrollTop()) { | ||
placement = 'top' | ||
} else if (tpt.top > $(window).scrollTop()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless my eyes are failing me, this condition is exactly the same as that of the previous else if
, which means that the next line is dead code.
Really: 'maid' instead of 'made'? I must get some sleep. |
After rediscovering this PR, I'm now curious how it compares with #8398. |
I think my javascript is a bit 'smarter' as it checks all positions till it finds enough room. |
not crzy about your solution - does a lot of unnecessary work calculating all the possible results |
If you have a solid solution that actually works, I would love to see it get into BootStrap :) |
The issue with that is that it only places the tooltip in one possible other position if there is no room in the target position, and it doesn't check if there is room there. So if you have your position set to right and there is just not enough room, it places it on the left. Even if there is even less room there. Also that code is doing calculations that are not used. |
I update tooltip v2.3.2 with @nonumber 's code. All browsers except IE (currently I am using IE9) work well. Sorry, the problem was because I got a stupid typo-> filter: alpha(opacity=100);// before it was filter: alpha(opacity=1) :( Now the tooltips' auto positioning works great for IE 8 and IE9 ! |
Not sure if I should look into the feedback @procrastination gave, as this PR has been closed by @fat. @fat: What's the status on this? Sorry to bring up the M-word, but even the old version of Mootools has a great positioning thing going on in their tooltips: http://demos111.mootools.net/Tips |
@nonumber did you ever get a solid solution for this or some plug in created? |
I have written and used this extra script for some time now: |
Thanks @nonumber ! |
@nonumber I ran that file through JSHint and got the following errors, can you correct it?
|
That's because it uses jQuery. |
For each case, you may want to add $tip.addClass('top'); or $tip.addClass('left'); so that we can get the arrows displaying properly. |
No need. That is already being done inside the |
Doesn't work for bootstrap 3.3.6? Error shown on console for bootstrap.js. Is there a solution that calculates the viewport of a canvas, when the popover is inside this canvas? |
This feature has been addressed in Bootstrap v4. |
This patch changes the positioning of the tooltip when there is no room for the tooptip in the position it would normally show.
As discussed here: #7399