DockYard / ember-in-viewport

Detect if an Ember View or Component is in the viewport @ 60FPS
MIT License
245 stars 91 forks source link

onEvent(callback) API doesn't work #254

Closed MaxKrai closed 4 years ago

MaxKrai commented 4 years ago

Description

If we use the onEnter() API from Usage example callbacks will not be fired in browsers where IntersectionObserver is not supported (e.g. IE):

const { onEnter } = this.inViewport.watchElement(element);
onEnter(this.didEnterViewport.bind(this));

Appearance of element in viewport leads to idle calling of noop() here

Workaround

Use modifier or pass callback to watchElement:

this.inViewport.watchElement(element, {}, this.didEnterViewport.bind(this));
snewcomer commented 4 years ago

@MaxKrai 👋 Thx for the issue. I converted some of our dummy app examples to use this and the tests/ember serve seem to work correctly. Possible to identify what is different than our examples?