如何从 <animate> 元素 (SVG) 切换特定 <use> 标签

问题描述 投票:0回答:1
svg svg-animate
1个回答
0
投票

<svg xmlns="http://www.w3.org/2000/svg">

    <defs>
        <rect id="rectangle" fill="red" width="25" height="25">
            <animate 
                attributeName="fill" 
                values="red;blue;green;red"
                dur="1s" 
                repeatCount="indefinite"
            />
            
        </rect>
    </defs>

    <!-- i want this to have both animations -->
    <use id="rect1" href="#rectangle" >
    <animate 
                attributeName="x" 
                values="0;50;0" 
                dur="1s" 
                repeatCount="indefinite"
            />            
    </use>

    <!-- i want this one to inherit only the fill animation  -->
    <use id="rect2" href="#rectangle" y="50" />

</svg>

© www.soinside.com 2019 - 2024. All rights reserved.