Created
April 17, 2015 22:22
-
-
Save poteto/cc39d464955c82d82048 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
_setViewportEntered(context=null) { | |
Ember.assert('You must pass a valid context to _setViewportEntered', context); | |
const $viewportCachedEl = get(this, '$viewportCachedEl'); | |
const viewportUseRAF = get(this, 'viewportUseRAF'); | |
const elementId = get(this, 'elementId'); | |
const tolerance = get(this, 'viewportTolerance'); | |
const height = $(context) ? $(context).height() : 0; | |
const width = $(context) ? $(context).width() : 0; | |
let boundingClientRect; | |
if ($viewportCachedEl) { | |
boundingClientRect = $viewportCachedEl[0].getBoundingClientRect(); | |
} else { | |
boundingClientRect = set(this, '$viewportCachedEl', this.$())[0].getBoundingClientRect(); | |
} | |
const viewportEntered = isInViewport(boundingClientRect, height, width, tolerance); | |
set(this, 'viewportEntered', viewportEntered); | |
if ($viewportCachedEl && viewportUseRAF) { | |
rAFIDS[elementId] = window.requestAnimationFrame( | |
bind(this, this._setViewportEntered, context) | |
); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment