Using GSAP instead of tween and timeline

 Using GSAP instead of tween and timeline


Timeline and tween are older version of Gsap so you can use both using just from new statement called gsap, 

For gsap include the following script tag;


<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js" integrity="sha512-gmwBmiTVER57N3jYS3LinA9eb8aHrJua5iQD7yqYCKa5x6Jjc7VDVaEA0je0Lu0bP9j7tEjV3+1qUm6loO99Kw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

for latest script tag visit CDN gsap code

simple tween using gsap statement


gsap.to(".boxes", {
    duration:1,
    x:250,
    y:300,
    backgroundColor : "yellow",
    rotation:360,
    stagger : 0.1

})


that stagger makes time gap between different element, 
here when one box starts to animate, then after 0.1s another box get animated

syntax: 


gsap.method("target", {properties for animation})


method = .to,  .from, fromTo, 

1 .from = you define the starting values to animate
2 .to = you define the ending values to animate
3 .fromTo = you define the starting and ending values.





Comments

Popular posts from this blog

CSS simple grid layout

Gsap timeline position parameters

GSAP Timelines