[英]How to draw animation from end of the line (SVG)?
I have this SVG animation HERE , now if you see the SVG, you will see that the dashed lines get drawn, the code that draws the lines is as follows: 我在这里有这个SVG动画,现在,如果您看到SVG,您将看到绘制了虚线,绘制线条的代码如下:
$(document).ready(function() {
$("#sec-three").waypoint(function(direction) {
/* code for first line animation */
var offset = parseInt($('#move-opacity').attr("offset"));
setInterval(function() {
$('#move-opacity').attr("offset", offset + "%");
if (offset < 100) {
$('#last-opacity').attr("offset", (offset + 1) + "%");
}
offset++;
}, 25);
/* code for secound line animation */
var offset1 = parseInt($('#move-opacity-1').attr('offset'));
setInterval(function() {
$('#move-opacity-1').attr("offset", offset + "%");
if (offset < 90) {
$('#last-opacity-1').attr("offset", (offset + 1) + "%");
}
offset++;
}, 25);
$("#lock").attr( "class" , "animated bounceInUp");
$("#quote-icon").attr( "class" , "animated bounceInUp delay-05s");
}, {
offset: '75%'
});
$("#lock").addClass("animated bounceInUp");
});
Now the animation drawing for the first black dashed line is perfect, but the drawing animation for second dashed line (the yellow dashed line) is not the way I want it to be, IE I would really like is the line gets drawn in the opposite direction, as of now the arrow gets drawn first, what I really want is for the animation to start from the end of the line, how do I make that possible? 现在,第一个黑色虚线的动画绘制是完美的,但是第二个虚线(黄色虚线)的绘制动画不是我想要的样子,IE,我真的很想在相反的方向绘制线条方向,从现在开始首先绘制箭头,我真正想要的是动画从行的结尾开始,如何使之成为可能?
You just need to reverse the linearGradient
definition for the yellow gradient like in the below code block and also reverse the corresponding jQuery code. 您只需要反转黄色渐变的
linearGradient
定义(如下面的代码块中一样),并且还反转对应的jQuery代码。
<defs>
<linearGradient id="yellow-gradient">
<stop offset="100%" id="move-opacity-1" stop-opacity="0" stop-color="#ffde17" />
<stop offset="100%" id="last-opacity-1" stop-opacity="1" stop-color="#ffde17" />
</linearGradient>
</defs>
var offset1 = parseInt($('#move-opacity-1').attr('offset'));
setInterval(function() {
if (offset1 > 0) {
$('#move-opacity-1').attr("offset", offset1 + "%");
$('#last-opacity-1').attr("offset", (offset1 + 1) + "%");
}
offset1--;
}, 25);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.