Jump to content
Search Community

Successive animations for a single image

rafil test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I have an image. I want to move it to the left until a certain scroll position, then move it back right. How do I do this? What I have doesn't seem to be working. This is what I have:

 

  var controller = $.superscrollorama(),
  handleComplete = function(elem) {
    console.log('complete', elem);
    $('#'+elem).css('rotation', 0);
  };
  
  controller.addTween($('#one'),
    (new TimelineLite())
      .append([
        TweenMax.to($('#likeSong'), .5, {css:{left: "45px"}}),
        TweenMax.to($('#likeSong'), .5, {css:{left: "45px"}})
      ]),
        500, // scroll duration of tween in pixels
        500); // offset (helps with timing when needed)
Link to comment
Share on other sites

Both of your tweens are identical (both to left:45), so you aren't going to see anything happen during the second one (it will be tweening from 45 to 45...).

 

e.g. let's say likeSong starts at 100px, you could do one of these:

// ABSOLUTE
TweenMax.to($('#likeSong'), .5, {left: "45px"}),
TweenMax.to($('#likeSong'), .5, {left: "100px"})

// RELATIVE
TweenMax.to($('#likeSong'), .5, {left: "-=55px"}),
TweenMax.to($('#likeSong'), .5, {left: "+=55px"})
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...