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

adjust tooltip placement when rendered off screen to the right (previously only happened on the left) #12733

Closed
wants to merge 1 commit into from

Conversation

fieldsco
Copy link

I modified the bootstrap tooltip (and by extension popovers) to include behavior that previously only happened when the tooltip was cut off on the left side of the screen. When a tooltip was activated, if a portion was to be rendered off the left side of the screen, it was shifted to the right and the arrow was moved to the left. This did not happen when cut off to the right side. This code accomplishes the same desired behavior on both sides.

…screen to the RIGHT. Previously was only doing this on the left (x: 0)
@cvrebert cvrebert added this to the v3.2.0 milestone Feb 13, 2014
@PaRoxUs
Copy link

PaRoxUs commented Feb 21, 2014

Great that you have adressed this issue! Although the placement of the arrow breaks the border-radius when it is very close to the right or left edge.

I don't know if it is only my case but this works better for me:
if (delta > (dimension/2)+40) this.arrow().css(position, "10%")
// avoid placing arrow at 100%
else if (delta < ((dimension/2)+40)*-1) this.arrow().css(position, "90%")
// if we shifted the tip to the right...
else if (delta > 0) this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
// if we shifted the tip to the left...
else if (delta < 0) this.arrow().css(position, delta ? (100 - (50 * (1 - Math.abs(delta / dimension))) + "%") : '')

@fieldsco
Copy link
Author

Thank you! I'm not sure why it wasn't accepted.. this is my first
contribution. Should I resubmit with your code?

On Fri, Feb 21, 2014 at 3:49 AM, Pontus Karlsson
[email protected]:

Great that you have adressed this issue! Although the placement of the
arrow breaks the border-radius when it is very close to the right or left
edge.

I don't know if it is only my case but this works better for me:
if (delta > (dimension/2)+40) this.arrow().css(position, "10%")
// avoid placing arrow at 100%
else if (delta < ((dimension/2)+40)*-1) this.arrow().css(position, "90%")
// if we shifted the tip to the right...
else if (delta > 0) this.arrow().css(position, delta ? (50 * (1 - delta /
dimension) + "%") : '')
// if we shifted the tip to the left...
else if (delta < 0) this.arrow().css(position, delta ? (100 - (50 * (1 -
Math.abs(delta / dimension))) + "%") : '')

Reply to this email directly or view it on GitHubhttps://github.com//pull/12733#issuecomment-35708954
.

@mdo mdo removed the css label Feb 21, 2014
@fat
Copy link
Member

fat commented Mar 17, 2014

duplicate of this i believe #12328

@fat fat closed this Mar 17, 2014
@mdo mdo removed this from the v3.2.0 milestone Mar 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants