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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Report zero visibility for zero size element #30105
Conversation
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.
Great catch!
// zero element size, high resolution screen. | ||
inOb.callback([ | ||
{ | ||
target, | ||
intersectionRatio: 0.8, | ||
intersectionRect: layoutRectLtwh(0, 0, 1, 1), | ||
boundingClientRect: layoutRectLtwh(1, 1, 10, 0.452), | ||
}, | ||
]); | ||
expect(model.getVisibility_()).to.equal(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.
Nice check!
@@ -872,7 +872,6 @@ export class VisibilityManagerForDoc extends VisibilityManager { | |||
Number(intersection.width), | |||
Number(intersection.height) | |||
); | |||
// TODO(#29618): Remove after ampim investigation |
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.
Is there any more cleanup 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.
Yes. We need to move all the related error logs.
I removed this TODO because boundingClientRect
needs to stay because we need element's width/height value.
@@ -908,6 +906,12 @@ export class VisibilityManagerForDoc extends VisibilityManager { | |||
intersectionRatio = Math.min(Math.max(intersectionRatio, 0), 1); | |||
const id = getElementId(target); | |||
const trackedElement = this.trackedElements_[id]; | |||
if (boundingClientRect.width < 1 || boundingClientRect.height < 1) { |
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.
should this be collapsed with the declaration above?
if (width<1 || height<1) {
// Set intersectionRatio to 0 when the element is not visible.
// Use < 1 because the width/height can be a double values.
intersectionRatio = 0;
} else {
intersectionRatio = Math.min(Math.max(intersectionRatio, 0), 1);
}
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.
done
* check belement size before setting visible percentage * fix test * nit
)" (ampproject#30284) This reverts commit 584158c.
Closes #29946