Hello everybody,
i've a SVG file with lot of objects and I want to animate them in a Timeline.
These objects can be complex (a group with 2 or 3 shapes and paths) and i want create a function for each type of object (arrow, people, explanation,...) and call function in a timeline (with object in parameter).
For exemple, a arrow object :
<g id="fleche2">
<g>
<path class="st0" d="M56,237.5v43v31v23v53c0,5.5,4.4,10,9.9,10h87.9c5.4,0,9.9-4.5,9.9-10v-97c0-5.5,4.4-10,9.9-10h116.5"/>
<g>
<polygon class="st1" points="287.3,276.8 288.9,280.5 287.3,284.2 296,280.5 "/>
</g>
</g>
</g>
To animate the arrows, I use this function (with 2 parameters : arrow id and rotation angle) :
function animeArrow(flecheInput,angle){
var fleche=flecheInput
var arrow = fleche.find('path')
var arrowHead = fleche.find ('polygon')
var motionPath = MorphSVGPlugin.pathDataToBezier(arrow, {align:arrowHead});
TweenLite.set(arrowHead, {xPercent:-50, yPercent:-50, transformOrigin:"center center"});
TweenLite.to(arrowHead, 15, {bezier:{values:motionPath, type:"cubic", autoRotate: angle}});
TweenMax.fromTo(arrow, 15 , {drawSVG: '0% 0%'}, {drawSVG: '0 100%'})
}
and to set it in a timeline :
var tl = new TimelineMax();
tl
.call(animeArrow,[($("#fleche1")),270],this, 1)
.call(animeArrow,[($("#fleche2")),0],this, 15)
.call(animeArrow,[($("#fleche3")),90],this, 30)
.call(animeArrow,[($("#fleche4")),180],this, 45)
.add( function(){ console.log( this.progress() ) } )
.call(animeArrow,[($("#fleche5")),45],this, 50)
This option works well but i'm not sure if it's the best way to manage Timeline (play, reverse, progress) and I must put manually the delay for each arrow.
And to add and manage other animation in this timeline, it's not easy...
Have you some ideas or example to improve my option ?
Thanks a lot !