简体   繁体   English

SVG-IE11-10变换旋转似乎不起作用

[英]SVG - IE11-10 Transform rotate doesn't appear to be working

Got an odd problem where transform rotate doesn't work on the circle in IE 11. 遇到了一个奇怪的问题,即IE 11中的圆上无法进行变换旋转。

The progress bar in blue you can see works clearly in any other browser but in IE 11 and 10 it is working fine. 您可以在任何其他浏览器中看到蓝色的进度条,但在IE 11和10中工作正常。

The problem is that the blue bar does not start at the top. 问题是蓝色条不在顶部开始。 In IE 11 you can see that it starts on the right. 在IE 11中,您可以看到它从右边开始。

JSfiddle: https://jsfiddle.net/o7sh7t45/ JSfiddle: https ://jsfiddle.net/o7sh7t45/

Javascript: Javascript:

    var svgs = document.querySelectorAll('.progress__pie')

    if (svgs) {
        [].forEach.call(svgs, function (svg) { 
            let percentage = svg.getAttribute('data-pct')
            let val = parseInt(percentage)
            let bar = svg.querySelector('.bar')
            if (isNaN(val)) {
                val = 100
            } else {
                let r: any = bar.getAttribute('r')
                let circumference = Math.PI*(r*2)

                if (val < 0) {
                    val = 0
                }
                if (val > 100) {
                    val = 100
                }

                percentage = ((100-val)/100 * circumference)
                svg.querySelector('.svg').style.strokeDashoffset = percentage.toString()
                bar.style.strokeDashoffset = percentage.toString()
            }
        })
    } 

IE doesn't support CSS transforms on SVG elements. IE不支持SVG元素上的CSS转换。 You would need to add the transform as an attribute on the SVG elements. 您需要将转换添加为SVG元素上的属性。

<circle ... transform="rotate(-90,100,100)" ../>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM