Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
poteto committed Apr 21, 2015
2 parents 6e3cbd8 + b6c97a1 commit 0f5a00c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ember-in-viewport
*Detect if an Ember View or Component is in the viewport @ 60FPS*

[Read the blogpost](https://medium.com/delightful-ui-for-ember-apps/creating-an-ember-cli-addon-detecting-ember-js-components-entering-or-leaving-the-viewport-7d95ceb4f5ed)

[![npm version](https://badge.fury.io/js/ember-in-viewport.svg)](http://badge.fury.io/js/ember-in-viewport) [![Build Status](https://travis-ci.org/dockyard/ember-in-viewport.svg)](https://travis-ci.org/dockyard/ember-in-viewport)

This `ember-cli` addon adds a simple, highly performant Ember Mixin to your app. This mixin, when added to a `View` or `Component` (collectively referred to as `Components`), will allow you to check if that `Component` has entered the browser's viewport. By default, the Mixin uses the `requestAnimationFrame` API if it detects it in your user's browser – failing which, it fallsback to using the more resource heavy Ember run loop and event listeners.

This software will not be ready for production use until `1.0.0`.

## Demo
- App: http://development.ember-in-viewport-demo.divshot.io/
- Source: https://github.com/poteto/ember-in-viewport-demo
Expand Down Expand Up @@ -103,3 +103,11 @@ export default Ember.Component.extend(InViewportMixin, {
* `ember build`

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).

## Legal

[DockYard](http://dockyard.com), Inc © 2015

[@dockyard](http://twitter.com/dockyard)

[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
8 changes: 4 additions & 4 deletions addon/mixins/in-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default Ember.Mixin.create({
}
},

_setViewportEntered(context=null) {
_setViewportEntered(context = null) {
Ember.assert('You must pass a valid context to _setViewportEntered', context);

const $viewportCachedEl = get(this, '$viewportCachedEl');
Expand Down Expand Up @@ -118,15 +118,15 @@ export default Ember.Mixin.create({
}
},

_setInitialViewport(context=null) {
_setInitialViewport(context = null) {
Ember.assert('You must pass a valid context to _setInitialViewport', context);

return scheduleOnce('afterRender', this, () => {
this._setViewportEntered(context);
});
},

_scrollHandler(context=null) {
_scrollHandler(context = null) {
Ember.assert('You must pass a valid context to _scrollHandler', context);

const viewportRefreshRate = get(this, 'viewportRefreshRate');
Expand All @@ -136,7 +136,7 @@ export default Ember.Mixin.create({
}, viewportRefreshRate);
},

_bindListeners(context=null, event=null) {
_bindListeners(context = null, event = null) {
Ember.assert('You must pass a valid context to _bindListeners', context);
Ember.assert('You must pass a valid event to _bindListeners', event);

Expand Down
2 changes: 1 addition & 1 deletion addon/utils/is-in-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const defaultTolerance = {
export default function isInViewport(boundingClientRect={}, height=0, width=0, tolerance=defaultTolerance) {
const { top, left, bottom, right } = boundingClientRect;
const tolerances = merge(defaultTolerance, tolerance);
let {
const {
top : topTolerance,
left : leftTolerance,
bottom : bottomTolerance,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-in-viewport",
"version": "0.2.1",
"version": "1.0.0",
"description": "Detect if an Ember View or Component is in the viewport @ 60FPS",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit 0f5a00c

Please sign in to comment.