-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 10,000
?
There was a problem hiding this comment.
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.)
LGTM |
Sorry, a couple late questions on this PR:
|
New vars: backgrounded, backgroundedAtLoad, elementX, elementY,
elementWidth, elementHeight, totalTime.
#1297