Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General refactor, fire Evented hooks #8

Merged
merged 4 commits into from
Apr 24, 2015
Merged

Conversation

poteto
Copy link
Collaborator

@poteto poteto commented Apr 24, 2015

Closes #7. This commit is a general refactor of the Mixin for performance improvements. The Mixin now fires actual 'hooks', named didEnterViewport and didExitViewport, which you can use in your app in place of observers. For example,

export default Ember.Component.extend(InViewportMixin, {
  handleDidEnterViewport: on('didEnterViewport', function() {
    console.log('entered');
  }),

  handleDidExitViewport: on('didExitViewport', function() {
    console.log('exited');
  })
});

Full changelog:

  • refactored _setViewportEntered
  • now triggers Events
  • removed unnecessary Ember.warn
  • updated debounce method to use fat arrow
  • explicitly set viewportEntered when removing viewportSpy to prevent race conditions setting it to false
  • renamed _viewportDidEnter to _unbindIfEntered which is more correct semantically
  • removed unnecessary var declaration
  • removed redundant initial call to _setViewportEntered
  • removed $viewportCachedEl in favour of using get(this, 'element')

Closes #7. This commit is a general factor of the Mixin for performance improvements. The Mixin now fires actual 'hooks', named `didEnterViewport` and `didExitViewport`, which you can use in your app in place of observers. For example,

```js
export default Ember.Component.extend(InViewportMixin, {
  handleDidEnterViewport: on('didEnterViewport', function() {
    console.log('entered');
  }),

  handleDidExitViewport: on('didExitViewport', function() {
    console.log('exited');
  })
});
```

Full changelog:

- refactored `_setViewportEntered`
- now triggers Events
- removed unnecessary Ember.warn
- updated debounce method to use fat arrow
- explicitly set `viewportEntered` when removing viewportSpy to prevent race conditions setting it to false
- renamed `_viewportDidEnter` to `_unbindIfEntered` which is more correct semantically
- removed unnecessary var declaration
- removed redundant initial call to `_setViewportEntered`
- removed $viewportCachedEl in favour of using `get(this, 'element')`
@rwjblue
Copy link
Contributor

rwjblue commented Apr 24, 2015

👍

poteto added a commit that referenced this pull request Apr 24, 2015
General refactor, fire Evented hooks
@poteto poteto merged commit ac69332 into develop Apr 24, 2015
@poteto poteto deleted the feature/7-evented-hooks branch April 24, 2015 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants