简体   繁体   English

CSS animation 导致过滤器过渡中断(在镀铬中)

[英]CSS animation causes filter transition to break (in chrome)

I have several <a> in my html which are styled to have various images for their backgrounds.我的 html 中有几个<a> ,它们的背景设计为具有各种图像。 The desired behavior is for these <a> to be animated and scrolling across the page, as well as to have a grayscale filter applied.期望的行为是使这些<a>动画化并在页面上滚动,以及应用灰度过滤器。 Then, when they are hovered they revert to normal, non-grayscale mode.然后,当它们悬停时,它们会恢复到正常的非灰度模式。

Unfortunately, in the latest version of chrome the animation css rule seems to interfere with the transition.不幸的是,在最新版本的 chrome 中,animation ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 规则似乎干扰了过渡。 I have reproduced the error in the code snippet below.我在下面的代码片段中重现了错误。 Notice that upon first hovering over either of the animated <div> s, they will not transition to reveal their color, but rather jump to the end animation state (namely, filter: none ) instantly.请注意,在第一次将鼠标悬停在任一动画<div>上时,它们不会过渡以显示其颜色,而是会立即跳转到末尾 animation state (即filter: none )。 And no, making the hovered css say filter: grayscale(0) instead of filter: none does not fix it.不,让悬停的 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 说filter: grayscale(0)而不是filter: none不能解决它。

If immediately after this you move your mouse in an out of the <div> s bounds repeatedly, you will notice the transition appearing to work normally.如果在此之后立即将鼠标反复移出<div>的边界,您会注意到过渡似乎正常工作。 However if you move your mouse away for too long or try the other <div> , the transition breaks again.但是,如果您将鼠标移开太久或尝试其他<div> ,则过渡会再次中断。

I have not found this to be an issue in Firefox or Brave, but what's more I seem to remember that when I implemented this feature in my site I tested it in chrome and it worked , so it must have been broken in the meantime.我没有发现这在 Firefox 或 Brave 中是一个问题,但更重要的是,我似乎记得当我在我的站点中实现此功能时,我在 chrome 中对其进行了测试并且它有效,所以它一定在此期间被破坏了。 I'm really stumped on how I might be able to fix this, or in the case that it is a bug in chrome at least work around it temporarily.我真的很难过我如何能够解决这个问题,或者如果它是 chrome 中的一个错误,至少可以暂时解决它。

 .thing { background-color: red; width: 50px; height: 50px; filter: grayscale(1); transition: filter 1s; }.thing:hover { filter: none; }.broken { animation: move linear 10s infinite; } @keyframes move { 0% { transform: translateX(0%); } 50% { transform: translateX(500%); } }
 <div class="broken thing">TEST1</div> <div class="broken thing">TEST2</div> <br> <div class="thing">noanim</div> <div class="thing">noanim</div>

Turns out is was a bug in chrome.原来是 chrome 中的一个错误。 The version in which I was encountering the error was Version 102.0.5005.115 , 64-bit.我遇到错误的版本是 64 位版本102.0.5005.115

As misterManSam pointed out, updating seems to solve the issue.正如misterManSam 指出的那样,更新似乎可以解决问题。 After relaunching chrome to finish the update (now using Version 103.0.5060.66 ) the transition behaves as expected.重新启动 chrome 以完成更新(现在使用版本103.0.5060.66 )后,转换的行为与预期一致。

I assumed I had the latest version since chrome was not asking me to update, but annoyingly only by going to chrome://settings/help was I able to see that I had to restart chrome to finish updating.我以为我拥有最新版本,因为 chrome 没有要求我更新,但令人讨厌的是,只有转到chrome://settings/help才能看到我必须重新启动 chrome 才能完成更新。 For anyone facing this issue, make sure your browser is fully updated by relaunching.对于遇到此问题的任何人,请确保您的浏览器通过重新启动完全更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM