我正在尝试使用 SVG animate 和 animateTransform。使用 mouseover 和 mouseout 触发动画。
我制作的第一个示例在 mouseover 和 mouseout 事件期间更改了对象颜色,并且似乎运行良好。
在第二个中,我尝试使用:fill =“freeze”additive =“sum”来更改 mouseover 和 mouseout 事件期间的旋转。
但似乎只在第一次鼠标悬停时运行良好,所有下一个鼠标悬停事件都以奇怪的方式失败。
我通过更改所有参数尝试了很多次,但我认为,也许这是一个 SVG 错误。
感谢您的帮助
这是链接
https://www.googledrive.com/host/0BwRlR3z6e0egY2RtWXZmVmU1Y0U/test_mouse_in_out.svg
这是代码
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" width="842px" height="595px" viewBox="0 0 842 595" enable-background="new 0 0 842 595" xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<path transform="matrix(1 0 0 1 552.381 250.537)" stroke-width="1.4834077083798625" stroke-miterlimit="3" stroke="#000000" fill="#3D70B1" d="... ">
<animateTransform xmlns="http://www.w3.org/2000/svg" attributeName="transform" type="rotate" begin="mouseover" dur="1" repeatCount="1" fill="freeze" additive="sum" calcMode="spline" keySplines=".5 0 .5 1" values="0 50 25;180 50 25"/>
<animateTransform xmlns="http://www.w3.org/2000/svg" attributeName="transform" type="rotate" begin="mouseout" dur="2" repeatCount="1" fill="freeze" additive="sum" calcMode="spline" keySplines=".5 0 .5 1" values="0 50 25;-180 50 25"/>
</path>
<path transform="matrix(1 0 0 1 150.733 232.565)" stroke-width="1.0106517551310161" stroke-miterlimit="3" stroke="#000000" fill="#2128DF" d="...">
<animate xmlns="http://www.w3.org/2000/svg" attributeName="fill" attributeType="CSS" begin="mouseover" dur="0.5" restart="whenNotActive" repeatCount="1" fill="freeze" to="#FF0000"/>
<animate xmlns="http://www.w3.org/2000/svg" attributeName="fill" attributeType="CSS" begin="mouseout" dur="0.5" repeatCount="1" fill="freeze" to="#2128DF"/>
</path>
</svg>