Velocity JS SVG transform origin issue in Firefox and IE

故事扮演 提交于 2019-12-11 03:34:55

问题


I would like to rotate an SVG group from the center using transform-origin: 50% 50%; using Velocity JS. This works fine in Chrome but I've noticed that the transform origin is wrong in IE and Firefox. I've tried setting an extra transform origin value and also tried setting the transform origin as pixels instead of % etc but with no luck. Can anyone explain how to fix this problem?

I have a demo here http://codepen.io/styler/pen/wBRPEa?editors=101

Code snippet

CSS

.box {
  transform-origin: 50% 50%;
}

JS

var box = document.querySelector('.js-box');    
setInterval(function() {
  Velocity(box,
    {
      rotateZ: 0
    },
    {
      duration: 600
    },
    "easeIn"
  );
  Velocity(box,
    {
      rotateZ: 360
    },
    {
      duration: 1200
    },
    "easeOut"
  );
}, 2200);

I've tried rotating a plain div and the correct transform-origin works fine, seems to be SVG related.

来源:https://stackoverflow.com/questions/29170197/velocity-js-svg-transform-origin-issue-in-firefox-and-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!