Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feature detection for the vector-effect property in SVG?

SVG Tiny 1.2 defines a property called vector-effect.

<path vector-effect="non-scaling-stroke" stroke-width="2"></path>

With the above path, the stroke width will always be 2 pixels, even if the element gets scaled (due to a transform on a parent g element, for example).

This property seems to work in most of the SVG-supporting browsers, but not in IE9 and IE10.

Is there any way to feature-detect this property?

like image 762
callum Avatar asked Nov 17 '25 17:11

callum


1 Answers

This works for me on Firefox and IE 9.

  <script>
    var elm = document.createElementNS("http://www.w3.org/2000/svg", "g");
    if (elm.style.vectorEffect != undefined) {
      alert("Supported");
    } else {
      alert("Not Supported");
    }
  </script>

Alternatively you could try Modernizr. Something like this I suppose.

Modernizr.testProp('vectorEffect')
like image 147
Robert Longson Avatar answered Nov 19 '25 06:11

Robert Longson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!