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

Fix CSS transitions on sidebar #19811

Merged
merged 2 commits into from Dec 18, 2018
Merged

Conversation

signalcat
Copy link
Contributor

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 the visibility property. Toggling display appears to interrupt the CSS transition property, whereas toggling visibility does not. The other solution proposed in the thread works but is dependent on the value of ANIMATION_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 than ANIMATION_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.

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@signalcat
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

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);

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.

@cathyxz
Copy link
Contributor

cathyxz commented Dec 17, 2018

Ping @signalcat. We'd love to get this PR merged if possible. It looks like a simple change to use i-amphtml-ghost instead of amp-hidden and reverting those extra CSS definitions will suffice. Do you know when you might be able to make this change? If you don't have time to work on it, I'd be happy to see this through.

@cathyxz
Copy link
Contributor

cathyxz commented Dec 18, 2018

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?

@cathyxz cathyxz self-assigned this Dec 18, 2018
@cathyxz cathyxz merged commit b7d58fd into ampproject:master Dec 18, 2018
bramanudom pushed a commit to bramanudom/amphtml that referenced this pull request Dec 19, 2018
* Fix CSS transitions on sidebar

* Use i-amphtml-ghost css class instead of amp-visible
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
* Fix CSS transitions on sidebar

* Use i-amphtml-ghost css class instead of amp-visible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

amp-sidebar animations don't respect the CSS transition properties.
5 participants