-
-
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
Add tooltip viewport
option, respect bounds of the viewport
#12328
Conversation
@benogle The tests are failing on Windows browsers: https://travis-ci.org/twbs/bootstrap/builds/17360227 |
Is there a way to figure out which test actually failed? |
I get that I can see this, but there's no info on what test actually was the failing one |
Yeah, there's not yet an easy way to get more fine-grained test result info from the automated tests. The Sauce guys are working on improving that. For now, you're gonna have to test it manually by opening |
Right... I'm installing a windows VM. |
Also some notes: The linter fails
And when I |
@benogle Be sure that your copy of csslint is up-to-date. I can't repro that error with
|
Ok, tests pass, and in one commit. |
Sauce and BrowserStack tests do indeed pass: https://travis-ci.org/twbs/bootstrap/builds/17381593 |
@@ -42,6 +46,7 @@ | |||
this.type = type | |||
this.$element = $(element) | |||
this.options = this.getOptions(options) | |||
this.$viewport = this.options.viewport.selector ? $(this.options.viewport.selector) : $(this.options.viewport) |
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.
should you check for this.options.viewport
first? …
this.options.viewport && this.options.viewport.selector
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.
I've changed this around to support a null viewport if you dont want it to be constrained.
@benogle the offset function was for setting |
this looks good to me… small nit with the $viewport condition |
@fat, I've rebased to current master, and addressed the |
rad |
@@ -42,6 +46,9 @@ | |||
this.type = type | |||
this.$element = $(element) | |||
this.options = this.getOptions(options) | |||
this.$viewport = !this.options.viewport ? null : | |||
this.options.viewport.selector ? $(this.options.viewport.selector) : | |||
$(this.options.viewport) |
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.
you'll want to line all the =
signs up above this declaration. also you can clean up this ternary
this.$element = $(element)
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
var viewportDimensions = this.getPosition(this.$viewport) | ||
|
||
if (/right|left/.test(placement)) { | ||
var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll |
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.
Offsets for all edges for clarity.
Alright, alignment and cleanup finished. |
Passes Sauce browser tests: https://travis-ci.org/twbs/bootstrap/jobs/21276179 |
lgtm to me – thanks @benogle 💪 |
@fat So, merge this? |
Add tooltip `viewport` option, respect bounds of the viewport
😍 |
🎉 |
〽️ |
To me it's unclear how to use the |
I'd expect this to also work with a DOM object instead of a selector |
Currently tooltips do not respect their container. eg. I have a button jammed up against the right side of the page, and place a tooltip on the top, it will stick out of the page.
So I added two new options:
viewport
: defaults to'body'
. It's the selector the tip should stay inside.viewport: padding
: how far, in px should it stay from the edgesWith changes from the original at #11593. The tests pass for me in firefox.
@fat: What was the new offset method you mentioned in the other pull?