Skip to content

Instantly share code, notes, and snippets.

@poteto
Created April 17, 2015 22:05
Show Gist options
  • Save poteto/e8991ba667fa8380280c to your computer and use it in GitHub Desktop.
Save poteto/e8991ba667fa8380280c to your computer and use it in GitHub Desktop.
_addObserverIfNotSpying() {
const viewportSpy = get(this, 'viewportSpy');
if (!viewportSpy) {
this.addObserver('viewportEntered', this, this._viewportDidEnter);
}
},
_viewportDidEnter() {
const viewportEntered = get(this, 'viewportEntered');
const viewportSpy = get(this, 'viewportSpy');
if (!viewportSpy && viewportEntered) {
this._unbindListeners();
this.removeObserver('viewportEntered', this, this._viewportDidEnter);
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment