-
Notifications
You must be signed in to change notification settings - Fork 6.7k
allow {placement: "mouse"} option for tooltip and popover #176
Comments
Hmm... In theory this should be doable, but it's not going to be pretty. This is really off-the-cuff, but... There's no way to get the mouse position without hooking into the
But there are a few challenges; I don't know how I feel about this. Why did the Twitter folk reject this? I may have to test it and see... What does everyone else think? |
For what it's worth, wouldn't have to change the placement on each mousemove so that the tooltip followed the mouse; could be preferable to have it stay put until mouseleave. That's the behavior of the stackoverflow hack, and playing with it in the thing I'm making, I think that's actually preferable. |
By the way, the stackoverflow hack I linked to fails to take into account the tooltip's own width and height when figuring out where to position it. It should instead do something like var offset = Math.max(actualWidth - (window.innerWidth - window.mousePos.x), 0);
tp = {top: window.mousePos.y, left: window.mousePos.x - offset}; |
@joshdmiller What do you think about this one? It sounds like a rather specific use-case for me so it would be -1 from my side. If someone needs it it should be easy to build with a new positioning service and I don't feel like it is common enough to justify additional bytes. WDYT? |
Just wanted to say I can understand thinking my svg example in the bootstrap ticket I opened is too specific a use-case to support. But the other people who asked for this had way less specific-seeming use cases, for whatever it's worth. Totally reasonable if you still want to reject this in favor of just maintaining parity with Twitter Bootstrap. If so, any tips for how to hook a custom mouse-based positioning service into ui-bootstrap's existing tooltip would be much appreciated. Thanks for your consideration! |
@pkozlowski-opensource I could go either way on this one. It's a cool feature, but I'm not sure what a clean implementation would look like; in some cases it makes sense to have it appear where the mouse first made contact while in others it would make sense to follow the mouse. So my opinion is "meh". I'll go with the consensus. |
Closing for now. @Skivvies fell free to open a PR if you think it is generic enough and wouldn't add too many bytes. |
Hey @pkozlowski-opensource, @joshdmiller, et al., I got this working with a very minimal change: This is all that's necessary to support my use case, but if you would need this to be modified in any way before you could accept a PR, I'd be happy to make whatever changes you'd like to see. |
@Skivvies Where is that |
@joshdmiller Oh right, I totally meant to check on that. I'm not sure where it's documented, but WebKit sets To make this cross-browser, you could add a single mousemove listener to the body, as in: |
I took another stab at it and think this is a better version: This handles binding the mouse listener in the $position service, so no more abusing $window. Opened a PR in #527. |
@Skivvies Great work, exactly what I was looking for. I modified my 0.8.0 version, cause I'm still using Twitter Bootstrap 2.3.2 |
Glad it was of some help to you @kwehrle! Unfortunately support for placement="mouse" was removed from angular-bootstrap some time ago pending a better implementation. Please see #1019 for more information. Perhaps we could coordinate with the angular-bootstrap core developers to get a new PR accepted? |
This was rejected for bootstrap core 😢 but we can show them! Whatayasay? Any interest?
The text was updated successfully, but these errors were encountered: