首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IE/Edge上的SVG脉冲动画

IE/Edge上的SVG脉冲动画
EN

Stack Overflow用户
提问于 2020-04-18 18:41:15
回答 1查看 121关注 0票数 0

我在svg圆圈上有脉冲动画,但是圆圈的transform: scale在IE/Edge上不起作用。在其他浏览器上工作得很好。有没有办法在没有任何jquery插件的情况下解决这个问题?

代码语言:javascript
复制
  .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);
    }

}

Codepen:https://codepen.io/burianovata/pen/oNjxqom

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-21 05:42:53

解决方案是使用JQuery更改圆半径。在所有浏览器上都是一样的,不需要额外的插件。我还尝试了GSAP3 - transform-origin和Snap.svg -尽管它也影响半径属性,但它在IE/Edge上不起作用。示例是上面列出的Codepen链接。

代码语言:javascript
复制
//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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61287797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档