Skip to content

Commit

Permalink
feat(tooltip): add simple fix to keep the tooltip inbounds (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
humanchimp authored and plouc committed Nov 20, 2019
1 parent 305a536 commit 395fc5e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/tooltip/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export const useTooltipHandlers = container => {
const x = event.clientX - bounds.left
const y = event.clientY - bounds.top

if (anchor === 'left' || anchor === 'right') {
if (x < bounds.width / 2) anchor = 'right'
else anchor = 'left'
}

setState({
isVisible: true,
position: [x, y],
Expand Down

0 comments on commit 395fc5e

Please sign in to comment.