TL;DR
Having created symbol-svg-sprite
and inserting its fragment using svg+use
, I want to use css-variables
inside #ShadowDOM for SVG presentation attributes
to change for example stroke-width="0"
in stroke-width="5"
, and the transition property
must work, the problem is that the stroke-width
values work at any event (:hover :active :focus) and transition
does not.
<svg style='display:none;' xmlns="http://www.w3.org/2000/svg">
<symbol id='symbol-id' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 20">
<path style='transition-duration: var(--custom-duration); transition-property: var(--custom-property);' stroke="var(--custom-stroke)" stroke-width="var(--custom-stroke-width)" fill="cyan" d="long..."
</symbol>
</svg>
<svg>
<use class="use-class" xlink:href="../transition-error.svg#symbol-id"></use>
</svg>
svg
outline 1px solid black
width 250px
height 250px
.use-class
--custom-stroke-width 0
--custom-duration .5s
--custom-property all
.use-class:hover
--custom-stroke-width 2
--custom-stroke blue
--custom-duration 2500ms
--custom-property all
When you hover the svg container, the values of the variables change and stroke stroke-width 0
smoothly flows into stroke-width 2
— this happens but without transition
although transition
assigned to <path>
this can be seen in
DevTools
<svg>
— <svg> <path d="..."> </svg>
<object></object>
with external css Demonstration can be seen on CodePen
https://codepen.io/Cloudesign/pen/bLaEWg
How to make CSS transition
work for external-svg-sprites
? I'm tired of fighting this :(
update As of September 2018, this still does not work everywhere except Firefox
Having carried out researches, it is revealed that this behavior is a bug.
At the moment on March 11, 2018 in the tested by me browsers under Windows 7, namely:
Does not work and is an ERROR
With the exception of
I would be grateful to those who supplement information on the state of work in:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With