Last active
May 22, 2019 02:46
-
-
Save nshimiye/a41f95eb5c8396d9a0d24b738e7071f3 to your computer and use it in GitHub Desktop.
Tooltip check for off screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkOffScreen() { | |
const tipElement = this.tipRef.nativeElement; | |
const tipContent = this.tipContentRef.nativeElement; | |
const { left: tipElementLeft } = tipElement.getBoundingClientRect(); | |
const { width: tipContentWidth } = tipContent.getBoundingClientRect(); | |
const { right: bodyRight } = document.body.getBoundingClientRect(); | |
this.isLeftOffScreen = tipElementLeft < tipContentWidth / 2; | |
this.isRightOffScreen = tipElementLeft + (tipContentWidth / 2) > bodyRight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment