Safari очень ограничен в отношении формата для объявления атрибутов <animate>
values
и keyTimes
.в этом браузере внутренние значения должны быть разделены одной точкой с запятой val1;val2
.
Но этого недостаточно для нашего случая ...
Существует очень странная ошибка, когда CSSфильтр не получит значения из анимации, а фильтр SVG:
#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);
}
<svg id="shell-svg" height="50">
<defs>
<filter id="shapeshift" color-interpolation-filters="sRGB" x="0%" y="0%" height="100%" width="100%">
<feColorMatrix type="matrix">
<animate
attributeType="XML"
id="fe1"
attributeName="values"
dur="4s"
repeatCount="indefinite"
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="0s"/>
</feColorMatrix>
</filter>
</defs>
<!-- our rectangle will have the animated filter -->
<rect fill="red" filter="url(#shapeshift)" width="100" height="20"/>
</svg>
<!-- the one applied through CSS won't animate -->
<div id="shell-bg" class="filtered"></div>
Я нашел обходной путь, хотя это настолько уродливо, что правильным действием было бы открыть проблему на багтрекере Webkit ...
Установка атрибута <feColorMatrix>
values
после применения фильтра CSS также заставит анимацию работать там ...
// yes, no need to set any actual value...
mat.setAttribute('values', '');
#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);
}
<svg id="shell-svg" height="0" width="0" style="position:absolute;pointer-events:none">
<defs>
<filter id="shapeshift" color-interpolation-filters="sRGB" x="0%" y="0%" height="100%" width="100%">
<feColorMatrix id="mat" type="matrix">
<animate
attributeType="XML"
id="fe1"
attributeName="values"
dur="4s"
repeatCount="indefinite"
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="0s"/>
</feColorMatrix>
</filter>
</defs>
</svg>
<div id="shell-bg" class="filtered"></div>