所以,我正在用SVG按钮制作动画,我想通过JavaScript将变换属性与opacity属性淡出组合起来进行动画。
代码应该像这样:(考虑它带着opacity 0和scale 0)
(我知道我这样做是不正确的,因为它会覆盖掉最后设置的属性)
我不确定是否可行,或者更好的方法是在CSS中添加一个带动画效果的类。
代码应该像这样:(考虑它带着opacity 0和scale 0)
(我知道我这样做是不正确的,因为它会覆盖掉最后设置的属性)
function hiA(){
pathA.setAttribute("transform", "scale(1)");
pathA.setAttribute("transform", "scale(.5)");
pathA.setAttribute("transform", "scale(1)");
pathA.setAttribute("opacity", "1");
}
同样的事情,但是反过来:(考虑到它是以不透明度1和比例1的形式出现的)
function byeA(){
pathA.setAttribute("transform", "scale(.5)");
pathA.setAttribute("transform", "scale(1)");
pathA.setAttribute("transform", "scale(0)");
pathA.setAttribute("opacity", "0");
}
我不确定是否可行,或者更好的方法是在CSS中添加一个带动画效果的类。
style.
而不是setAttribute
: https://www.w3schools.com/jsref/prop_html_style.asp - לבני מלכה