We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG 实现 Blink 动画
SVG SMIL Animation 同样也能实现对图形的闪烁效果,通过声明 attributeName 为 fill ,指定想要变化的颜色。设定动画时长,就会让 SVG 图形闪烁起来。核心代码:
<polygon fill="#4fd2dd" points="6,66 6,18 12,12 18,12 24,6 27,6 30,9 36,9 39,6 84,6 81,9 75,9 73.2,7 40.8,7 37.8,10.2 24,10.2 12,21 12,24 9,27 9,51 7.8,54 7.8,63"> <animate attributeName="fill" values="#4fd2dd;#235fa7;#4fd2dd" dur="0.5s" begin="0s" repeatCount="indefinite" /> </polygon>
GSAP 实现闪烁动画
继续沿用上例 SVG 闪烁边框,如何使用 GSAP 让边框闪烁起来呢,例子中的边框有三条 polygon ,我们注意到三条折线是同时进行闪烁动画的,每条折线都有自己的动画设定。所以在 GSAP 中我们不能使用 timeline,动画不是线性的,而是并行的。
我们先给折线定义好 id 属性
<div class="gs-border-blink"> <svg width="300px" height="300px" class="left-top"> <polygon id="line1" fill="#4fd2dd" points="6,66 6,18 12,12 18,12 24,6 27,6 30,9 36,9 39,6 84,6 81,9 75,9 73.2,7 40.8,7 37.8,10.2 24,10.2 12,21 12,24 9,27 9,51 7.8,54 7.8,63"> </polygon> <polygon id="line2" fill="#235fa7" points="27.599999999999998,4.8 38.4,4.8 35.4,7.8 30.599999999999998,7.8"></polygon> <polygon id="line3" fill="#4fd2dd" points="9,54 9,63 7.199999999999999,66 7.199999999999999,75 7.8,78 7.8,110 8.4,110 8.4,66 9.6,66 9.6,54"></polygon> </svg> </div>
// line 1, #4fd2dd -> #235fa7 -> #4fd2dd gsap .to('#line1', { fill:'#235fa7', repeat: -1, yoyo: true, duration: 0.25, repeatDelay: 0 }) gsap .to('#line1', { fill:'#4fd2dd', repeat: -1, yoyo: true, duration: 0.25, repeatDelay: 0.25 }); // line 2, #235fa7 -> #4fd2dd gsap .to('#line2', { fill:'#4fd2dd', repeat: -1, yoyo: true, duration: 0.3, repeatDelay: 0 }) // line 3, #4fd2dd -> transparent -> #235fa7 gsap .to('#line3', { fill:'transparent', repeat: -1, yoyo: true, duration: 0.5, repeatDelay: 0 }) gsap .to('#line3', { fill:'#235fa7', repeat: -1, yoyo: true, duration: 0.5, repeatDelay: 0.3 });
来源:https://segmentfault.com/a/1190000038676261
The text was updated successfully, but these errors were encountered:
No branches or pull requests
SVG 实现 Blink 动画
SVG SMIL Animation 同样也能实现对图形的闪烁效果,通过声明 attributeName 为 fill ,指定想要变化的颜色。设定动画时长,就会让 SVG 图形闪烁起来。核心代码:
GSAP 实现闪烁动画
继续沿用上例 SVG 闪烁边框,如何使用 GSAP 让边框闪烁起来呢,例子中的边框有三条 polygon ,我们注意到三条折线是同时进行闪烁动画的,每条折线都有自己的动画设定。所以在 GSAP 中我们不能使用 timeline,动画不是线性的,而是并行的。
我们先给折线定义好 id 属性
来源:https://segmentfault.com/a/1190000038676261
The text was updated successfully, but these errors were encountered: