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

[amp-analytics] More visibilitySpec vars. #3371

Merged
merged 3 commits into from
Jun 2, 2016
Merged

Conversation

avimehta
Copy link
Contributor

New vars: backgrounded, backgroundedAtLoad, elementX, elementY,
elementWidth, elementHeight, totalTime.
#1297

New vars: backgrounded, backgroundedAtLoad, elementX, elementY,
elementWidth, elementHeight, totalTime.
@@ -86,6 +86,9 @@ exports.rules = [
{
filesMatching: 'extensions/**/*.js',
mustNotDependOn: 'src/service/**/*.js',
whitelist: [
'extensions/amp-analytics/0.1/visibility-impl.js->src/service/viewer-impl.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This shouldn't be needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is very dangerous. Let's remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

height: br.height};
const intersection = rectIntersection(viewportRect, elementRect);
state[LOAD_TIME_VISIBILITY] = intersection != null
? Math.round(intersection.width * intersection.height * 10000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we do anything when br.width or br.height are 0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 10,000?

Copy link
Contributor Author

@avimehta avimehta Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows for two significant digits after decimal. So 12.344 becomes 12.34 and 12.346 becomes 12.35

Regarding br.width and br.height: I'll need to add checks for that. Currently that would be a problem.

(in practical cases, tracking 0 width/height elements does not make sense.)

@dvoytenko
Copy link
Contributor

LGTM

@avimehta avimehta merged commit 8dbfa36 into ampproject:master Jun 2, 2016
@rudygalfi
Copy link
Contributor

Sorry, a couple late questions on this PR:

  • Will documentation for the new variables get added in a separate (future) PR?
  • The example was updated with a visibility request but it doesn't look like it's actually configured to fire in the example. Is that coming later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants