Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
poteto committed Aug 20, 2016
1 parent fb64e25 commit 0e31648
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions addon/utils/is-in-viewport.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Ember from 'ember';

const assign = Ember.assign || Ember.merge;

const defaultTolerance = {
top: 0,
left: 0,
Expand All @@ -12,9 +11,12 @@ const defaultTolerance = {
const isAxisInViewport = function(start, startTolerance, end, endTolerance, limit) {
// Dimensions are fully LARGER than the viewport or fully WITHIN the viewport.
const exceedingLimit = (end + endTolerance) - (start + startTolerance) > limit;
return exceedingLimit
? start <= startTolerance && (end - endTolerance) >= limit
: (start + startTolerance) >= 0 && (end - endTolerance) <= limit;

if (exceedingLimit) {
return start <= startTolerance && (end - endTolerance) >= limit;
}

return (start + startTolerance) >= 0 && (end - endTolerance) <= limit;
};

export default function isInViewport(boundingClientRect = {}, height = 0, width = 0, tolerance = defaultTolerance) {
Expand All @@ -28,5 +30,5 @@ export default function isInViewport(boundingClientRect = {}, height = 0, width
} = tolerances;

return isAxisInViewport(top, topTolerance, bottom, bottomTolerance, height) &&
isAxisInViewport(left, leftTolerance, right, rightTolerance, width);
isAxisInViewport(left, leftTolerance, right, rightTolerance, width);
}

0 comments on commit 0e31648

Please sign in to comment.