【发布时间】:2020-05-04 18:46:51
【问题描述】:
我正在开发一个带有全屏加载屏幕的网站,一旦加载了网站中的所有内容,中间的框(其中有一个 SVG clip-path)就会故意变大直到填满整个屏幕。
但是,我试图弄清楚为什么在制作动画时框看起来很模糊。我尝试过所有 GPU 加速方法,包括 transform: translateZ(0)、backface-visibility 和 perspective,但无济于事。
#loading {position:fixed; width:100%; height: 100%; top: 0; left: 0; display: flex; align-items: center; justify-content:center; background: #34d1bf;}
#loading .bar {width: 169px; height: 160px; clip-path: url(#kframe); -webkit-clip-path: url(#kframe); background:#000; overflow: hidden; transform: translateZ(0); animation: loaded 2000ms linear forwards infinite;}
@keyframes loaded {
0% {transform: scale(1);}
1% {transform: scale(1);}
32% {transform: scale(1);}
33% {transform: scale(5);}
65% {transform: scale(5);}
66% {transform: scale(10);}
99% {transform: scale(10);}
100% {transform: scale(15);}
}
<div id="loading">
<div class="bar"></div>
</div>
<div style="height: 0; overflow: hidden;">
<svg width="0" height="0" viewBox="0 0 256 256">
<defs>
<clipPath id="kframe" clipPathUnits="objectBoundingBox">
<polygon transform="scale(0.00390 0.00390)" points="256,0 0,0 0,72 18,72 18,184 0,184 0,256 222.5,256 256,220 256,36 222.5,36 "/>
</clipPath>
</defs>
</svg>
</div>
更新:这是一张模糊最明显的一帧照片,在我电脑上的本地版本上进行了测试。经测试,它在 Chrome 和 Safari 上的发生率更高。
【问题讨论】:
-
很遗憾,我没有看到和/或理解您在制作动画时所说的模糊框是什么意思。你能给我们看一张照片并突出模糊区域吗?
-
@Richard 更新了屏幕截图。显然,我在上面编写的模拟比我本地主机上的类似原始版本运行得更快。