javascript - How to animate gradient offset using Velocity.js -
i want animate gradient "move" right , in order have animate offset property of stop element, right i'm succeeding animate stop-color property.
<lineargradient id="gr-simple" x1="0" y1="0" x2="100%" y2="0%"> <stop id = "first" stop-color="lightblue" offset="10%"/> <stop id = "second" stop-color="red" offset="90%"/> </lineargradient>
works:
$("#first") .delay(1500) .velocity({stopcolor: "#ff4e50" },{duration:1500});
does not work:
$("#first") .delay(1500) .velocity({offset: "50%"},{duration:1500});
any can appreciated. thanks
was looking same thing , stumbled upon pen : http://codepen.io/jorgeatgu/pen/niubs?editors=101
the trick seems using x1, x2, y1 , y2 values :
<lineargradient id="background" gradientunits="objectboundingbox" x1="0%" y1="0%" x2="0%" y2="100%"> <stop id="one" offset="0%" stop-color="crimson"/> <stop id="two" offset="100%" stop-color="cyan"/> </lineargradient>
and in js :
$("#background") .delay(500) .velocity({x2: "100%", y2: "0%" },{duration:1500, easing: "linear"})
i don't know yet properties should able find docs !
ps : sure animate colors on <stop>
, offsets on <lineargradient>
hope helps ! (even if i'm late)
loic
edit :
actually think animating offset should work, doesn't, guess moving whole gradient around using x1/x2/y1/y2 values option, did wanted
Comments
Post a Comment