【发布时间】:2018-06-08 08:25:33
【问题描述】:
我有一个看起来像这样的 svg:
<svg id="baseSplashGradient" width="720px" height="1024px" viewBox="0 0 720 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient x1="41.1044918%" y1="0%" x2="50%" y2="101.663162%" id="linearGradient-1">
<stop stop-color="#56CCF2" offset="0%"></stop>
<stop stop-color="#2F80ED" offset="100%"></stop>
</linearGradient>
</defs>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<polygon id="left-background" fill="url(#linearGradient-1)"
points="0 0 439.837891 0 720 1024 0 1024"></polygon>
</g>
</svg>
它形成了一种三角形的形状。我想弄清楚如何为点数组设置动画:
points="0 0 439.837891 0 720 1024 0 1024
看起来像这样:
points="0 0 720 0 720 1024 0 1024"
本质上,使形状成为矩形。使用translateX 之类的东西,我不确定如何与实际的points 交谈。
我可以移动整个 svg:
var svg = $('#baseSplashGradient'),
polygon = svg.find('polygon'),
points = polygon.attr('points'),
pointsArray = points.split(' ');
if (polygon.data('animating') === true) {
//
} else {
polygon.velocity({
translateX: '200px'
}, {
duration: 500
});
}
但这不是我想要完成的。任何建议将不胜感激!
【问题讨论】:
-
为什么不直接使用 SMIL?
-
通读帖子,我以为我读过
<animate>正在被弃用。 -
Chrome 弃用了它,然后他们改变了主意。所以目前不是
标签: animation svg css-animations velocity.js