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
/* global jest */ | |
var InfoBox = jest.genMockFunction().mockReturnThis(); | |
InfoBox.prototype = jest.genMockFunction(); | |
InfoBox.prototype.createInfoBoxDiv_ = jest.genMockFunction(); | |
InfoBox.prototype.getCloseBoxImg_ = jest.genMockFunction().mockReturnThis(); | |
InfoBox.prototype.addClickHandler_ = jest.genMockFunction(); | |
InfoBox.prototype.getCloseClickHandler_ = jest.genMockFunction().mockReturnThis(); | |
InfoBox.prototype.panBox_ = jest.genMockFunction(); |
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
{ | |
"name": "ember-in-viewport", | |
"version": "0.2.1", | |
"description": "Detect if an Ember View or Component is in the viewport @ 60FPS", | |
"directories": { | |
"doc": "doc", | |
"test": "tests" | |
}, | |
"scripts": { | |
"start": "ember server", |
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
import Ember from 'ember'; | |
import canUseDOM from 'ember-in-viewport/utils/can-use-dom'; | |
import canUseRAF from 'ember-in-viewport/utils/can-use-raf'; | |
import isInViewport from 'ember-in-viewport/utils/is-in-viewport'; |
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
import Ember from 'ember'; | |
const { merge } = Ember; | |
const defaultTolerance = { | |
top : 0, | |
left : 0, | |
bottom : 0, | |
right : 0 | |
}; |
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
const { | |
get, | |
set, | |
setProperties, | |
computed, | |
run, | |
on, | |
$, | |
} = Ember; |
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
_setInitialState: on('init', function() { | |
setProperties(this, { | |
$viewportCachedEl : undefined, | |
viewportUseRAF : canUseRAF(), | |
viewportEntered : false, | |
viewportSpy : false, | |
viewportRefreshRate : 100, | |
viewportTolerance : { | |
top : 0, | |
left : 0, |
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
viewportExited: not('viewportEntered').readOnly(), |
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
_setupElement: on('didInsertElement', function() { | |
if (!canUseDOM) { return; } | |
const viewportUseRAF = get(this, 'viewportUseRAF'); | |
this._setInitialViewport(window); | |
this._addObserverIfNotSpying(); | |
this._setViewportEntered(window); | |
if (!viewportUseRAF) { |
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
_setInitialViewport(context=null) { | |
Ember.assert('You must pass a valid context to _setInitialViewport', context); | |
return scheduleOnce('afterRender', this, () => { | |
this._setViewportEntered(context); | |
}); | |
}, |