【发布时间】:2019-11-01 14:05:58
【问题描述】:
我正在将动画 feColorMatrix 应用到外部图像背景,它在 Chrome 和 Firefox 中运行良好,但在 Safari 中根本不行......
#shell-bg {
width: 100vw;
height: 100vh;
z-index: 0;
background: url("https://picsum.photos/id/13/1000/800") no-repeat top center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
display: flex;
justify-content: center;
}
.filtered {
width: 100%;
filter: url(#shapeshift);
-webkit-filter: url(#shapeshift);
}
<div id="shell-bg" class="filtered"></div>
<svg id="shell-svg">
<defs>
<filter id="shapeshift" color-interpolation-filters="sRGB" x="0%" y="0%" height="100%" width="100%">
<feColorMatrix result="wispy" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0">
<animate
attributeType="XML"
id="fe1"
attributeName="values"
from="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"
to="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"
dur="10s"
values = "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 ; 0.8 0 0.04 0.04 0 0 0.8 0 0 0 0 0 0.8 0 0 0 -2 0 1 0 ; 1 -0.6 0.7 0.9 0 0 1.2 0 0 0 0 0 1 0 0 0 0 0 0.4 0 ; 1 0.2 0 0 0 0 1 0 0 0 0 0 1 0 0 -2.6 0 0 1 0 ; 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 ;"
keyTimes = "0 ; 0.5 ; 0.75 ; 0.85 ; 1"
begin="3s;fe1.end+3s"/>
</feColorMatrix>
</filter>
</defs>
</svg>
不确定是不是像 answer 这样的换行符,或者可能有更好的方法通过 javascript 为单独的 alpha 通道设置动画。任何想法表示赞赏!
【问题讨论】: