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-lightbox relayout children when transitionend #10811
Conversation
58e3945
to
85ed604
Compare
*/ | ||
reschedule_(event) { | ||
if (event.type == 'transitionend') { | ||
// Ignore the first transitionend event. |
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?
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.
amp-lightbox
by default apply transition: 'opacity 0.1s ease-in'
to its element. I am trying to ignore this specific transitionend
event here.
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.
(a) can we be more specific, i.e. by looking into event.target
or specific properties?
(b) given debounce don't we run a risk of missing the followup events?
(c) is this a bit deal if we proceed an extra time? I think runtime does additional debouncing naturally, right?
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.
a) I found it hard to use event property here. 'target' is not a good property to check since transition apply to lightbox element/ iframe element/iframe child element can all result in iframe size change.
b) c). Yes! I agree an extra scheduleLayout
doesn't hurt. changed.
85ed604
to
381ade2
Compare
bb285ca
to
3d3ff9c
Compare
// Iframe is not tracking iframe if open with user interaction | ||
if (this.isInContainer_ === undefined) { | ||
let ele = this.element; | ||
do { |
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 is just Element#closest
.
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.
changed
@@ -152,6 +160,8 @@ class AmpLightbox extends AMP.BaseElement { | |||
} | |||
// TODO: instead of laying out children all at once, layout children based | |||
// on visibility. | |||
this.element.addEventListener('transitionend', this.boundReschedule_); | |||
this.element.addEventListener('animationend', this.boundReschedule_); | |||
this.scheduleLayout(container); |
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.
Are these calls necessary now?
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. would still be useful for elements with relayoutNeeded = true
. amp-img for example.
PTAL |
Friendly ping : ) |
return true; | ||
// Iframe is not tracking iframe if open with user interaction | ||
if (this.isInContainer_ === undefined) { | ||
this.isInContainer_ = !!closest(this.element, element => { |
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.
Would be faster to just do a DOM query, as in closestBySelector(this.element, 'amp-lightbox|amp-sidebar')
. And even better is to define a shared class and do:
closestBySelector(this.element, '.i-amphtml-overlay');
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.
Applied 'i-amphtml-overlay'. I have concern on how people know about these classes when creating new components though.
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.
Yeah, we need to think about it. I'd recommend "copy paste" lightbox at this point :) But it's invariant here since devs still need to remember to whitelist name here otherwise.
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.
One nit, but otherwise LGMT on my side.
@@ -44,6 +44,12 @@ const ATTRIBUTES_TO_PROPAGATE = [ | |||
'scrolling', | |||
]; | |||
|
|||
/** @const {!Array<string>} */ | |||
const CONTAINER_LIST = [ |
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.
No longer needed?
@jridgewell PTAL |
Looks like this PR is causing a type error:
|
#10910 |
Schedule relayout to amp-iframe element, if placed inside
<amp-lightbox>
<amp-sidebar>
.Rewrite amp-iframe test.
fix #10657