Skip to content

Commit

Permalink
Fix minVisiblePercentage and maxVisiblePercentage (ampproject#6326)
Browse files Browse the repository at this point in the history
* Fix minVisiblePercentage and maxVisiblePercentage

* Remove 'only'
  • Loading branch information
lannka authored and Vanessa Pasque committed Dec 22, 2016
1 parent f947684 commit 9843cac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion extensions/amp-analytics/0.1/test/test-visibility-impl.js
Expand Up @@ -165,7 +165,9 @@ describe('amp-analytics.visibility', () => {
elementY: '23', // 13 + 10
elementWidth: '100',
elementHeight: '100',
loadTimeVisibility: '49', // (100 - 51) * (100 - 0) / 100
loadTimeVisibility: '49', // (100 - 51) * (100 - 0) / 100,
minVisiblePercentage: '63',
maxVisiblePercentage: '63',
totalTime: sinon.match(value => {
return isFiniteNumber(Number(value));
}),
Expand Down
6 changes: 4 additions & 2 deletions extensions/amp-analytics/0.1/visibility-impl.js
Expand Up @@ -495,8 +495,10 @@ export class Visibility {
? s[CONTINUOUS_TIME] + sinceLast : 0;
s[MAX_CONTINUOUS_TIME] = s[MAX_CONTINUOUS_TIME] !== undefined
? Math.max(s[MAX_CONTINUOUS_TIME], s[CONTINUOUS_TIME]) : 0;
s[MIN_VISIBLE] = s[MIN_VISIBLE] ? Math.min(s[MIN_VISIBLE], visible) : 101;
s[MAX_VISIBLE] = s[MAX_VISIBLE] ? Math.max(s[MAX_VISIBLE], visible) : -1;
s[MIN_VISIBLE] =
s[MIN_VISIBLE] ? Math.min(s[MIN_VISIBLE], visible) : visible;
s[MAX_VISIBLE] =
s[MAX_VISIBLE] ? Math.max(s[MAX_VISIBLE], visible) : visible;
s[LAST_VISIBLE_TIME] = Date.now() - s[TIME_LOADED];
}

Expand Down

0 comments on commit 9843cac

Please sign in to comment.