Actual hooks
With this release, you no longer need to use observers on viewportEntered
in your app. The Mixin now emits actual events that you can handle like you would any other native Ember hook:
export default Ember.Component.extend(InViewportMixin, {
// with prototype extensions disabled
handleDidEnterViewport: Ember.on('didEnterViewport', function() {
console.log('entered');
}),
handleDidExitViewport: Ember.on('didExitViewport', function() {
console.log('exited');
}),
// with prototype extensions enabled
handleDidEnterViewport: (function() {
console.log('entered');
}).on('didEnterViewport'),
handleDidExitViewport: (function() {
console.log('exited');
}).on('didExitViewport'),
// method override
didEnterViewport() {
console.log('entered');
},
didExitViewport() {
console.log('exited');
}
});
Changelog:
#8 Refactor and Evented hooks by @poteto (thanks to @rwjblue for reporting)