Created
June 23, 2017 12:41
-
-
Save saleh-old/9248a4d79a0093a73f77239e912aec04 to your computer and use it in GitHub Desktop.
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
add it to the data: | |
isInViewPort: false | |
listen for scroll event: | |
this.$eventHub.$on('scrolled', this.setViewPort); | |
action: | |
/** | |
* is the element in view port | |
* | |
* @return bool | |
*/ | |
setViewPort() { | |
let rect = this.$el.getBoundingClientRect(); | |
let html = document.documentElement; | |
if ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= (window.innerHeight || html.clientHeight) && | |
rect.right <= (window.innerWidth || html.clientWidth) | |
) { | |
this.isInViewPort = true; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment