animation not animating instead jumping to end

旧城冷巷雨未停 提交于 2020-05-09 06:20:56

问题


I am trying to use the SVG animate tag to change the path from a half fill to a complete fill

        <svg class="background-gradient" viewBox="0 0 100 100" preserveAspectRatio="none">
            <defs>
                <linearGradient id="grad">
                    <stop offset="0%" stop-color="rgba(82,181,244,.1)" stop-opacity="1"></stop>
                    <stop offset="100%" stop-color="rgba(70,215,255,.7)" stop-opacity="1"></stop>
                </linearGradient>
            </defs>
            <path id="scroll-path" d="M0 0 H100 v 100" fill="url(#grad)">
                <animate attributeName="d" from="M0 0 H100 v 100" to="M0 0 H100 L100 100 L0 100" dur="1s" repeatCount="indefinite" />
            </path>
        </svg>

Currently it just jumps from the beginning to the end of the animation and does not show the smooth fill I was hoping for in between.

Any ideas?


回答1:


For an animation to be smooth the path must have the same number and types of commands.

Your first path has 3 commands M H v

Your second path has 4 commands M H L L

You'll need to write the first path using 2 L commands instead of the v or the second as a v instead of the two L commands.



来源:https://stackoverflow.com/questions/36284414/animation-not-animating-instead-jumping-to-end

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