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
Fix CSS transitions on sidebar #19811
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
@@ -373,15 +373,15 @@ export class AmpSidebar extends AMP.BaseElement { | |||
}); | |||
this.maskElement_ = mask; | |||
} | |||
toggle(this.maskElement_, /* display */true); | |||
this.maskElement_.classList.toggle('amp-visible', true); |
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.
We already have a class that does the visibility hidden (though inverted from this) called i-amphtml-ghost
. If you remove it here, and add it for closeMask, you can avoid adding any CSS in this PR.
Another difference is that the validator prevents page authors from targeting classes starting with i-amp
. I don't think there is any reason for page authors to target this, so I think it would be better to restrict them from using it in the first place.
Ping @signalcat. We'd love to get this PR merged if possible. It looks like a simple change to use |
Sync-ed offline and it looks like @signalcat won't be able to get to this right now. Made the changes you requested, @sparhami PTAL? |
* Fix CSS transitions on sidebar * Use i-amphtml-ghost css class instead of amp-visible
* Fix CSS transitions on sidebar * Use i-amphtml-ghost css class instead of amp-visible
This PR fixes the problem where opening or closing the side bar does not respect the CSS transform property (closes #19777).
This bug was caused by #17988, which changed the toggle function to use the
display
property instead of thevisibility
property. Toggling display appears to interrupt the CSStransition
property, whereas togglingvisibility
does not. The other solution proposed in the thread works but is dependent on the value ofANIMATION_TIMEOUT
being greater than the time specified for the CSS transition property. This could potentially break if we try to overwrite the CSS transition property with a transition time greater thanANIMATION_TIMEOUT
. Reverting the sidebar mask toggle back to using the visibility property is slightly more robust. There is one minor caveat though: since the sidebar is hidden after a constant delay (ANIMATION_TIMEOUT = 350
), this means that the closing animation has to finish before that delay. But with the visibility toggle, at least this is not a problem for the opening animation.