html - IE/Edge 上的 SVG 脉冲动画
问题描述
我在 svg 圆圈上有脉冲动画,但transform: scale
圆圈在 IE/Edge 上不起作用。在其他浏览器上效果很好。有没有办法在没有任何 jquery 插件的情况下解决这个问题?
.cls-1, .cls-3, .cls-4, .cls-5, .cls-6, .cls-7, .cls-8 {
transform: scale(0,0);
-ms-transform: scale(0,0);
-webkit-transform: scale(0,0);
-moz-transform: scale(0,0);
-o-transform:scale(0,0);
opacity: 0;
transform-box: fill-box;
transform-origin: 50% 50%;
animation: pulse 2s infinite cubic-bezier(.5,.5,0,1);
}
@keyframes pulse {
25% {
opacity: 0.4;
}
100% {
transform: scale(1);
-ms-transform: scale(1);
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform:scale(1);
}
}
代码笔: https ://codepen.io/burianovata/pen/oNjxqom
解决方案
解决方案是使用 JQuery 更改圆半径。在所有浏览器上都一样,不需要额外的插件。我还尝试了 GSAP3——transform-origin 和 Snap.svg 有问题——尽管它也会影响半径属性,但它在 IE/Edge 上不起作用。示例在上面列出的 Codepen 链接上。
//Change radius to zero
function scale() {
if($('.map-circle').length) {
$('.map-circle')
.animate(
{'radius': 0},
{
step: function (radius) {
$(this).attr('r', radius);
},
duration: 800
}
);
}
}
//Change radius to initial size - 35.5
function pulse() {
if($('.map-circle').length) {
$('.map-circle')
.animate(
{'radius': 35.5},
{
step: function (radius) {
$(this).attr('r', radius);
},
duration: 1200
}
);
}
}
// Infinite animation
function animation() {
setInterval(
function () {
pulse();
scale();
}, 1000);
}
animation();
推荐阅读
- scala - ARIMA 与 Spark 的优势
- python-3.x - 更改从 print() 打印日期时间对象的方式?
- sql - DB2 SQL 将 IF ELSE 条件视为 DDL 语句?
- python - 如何测试两个熊猫分类系列是否仅在类别标签上有所不同
- javascript - Backstop JS - 在视图中的元素之后截取屏幕截图
- google-bigquery - 如果标准 SQL 不提供 _PARTITIONTIME 字段,如何在 BigQuery 中查询流式缓冲区
- c# - 查找并替换所有以 # 开头的单词并将带有标签的文本包装在 HTML 中
- python - Python - 以所需格式转置数据
- c# - 使用容器 url 上传文件 azure blob 存储
- docker - 如何记录对弹性搜索容器的所有查询?