Jump to content
Search Community

reverse change var value

vishal_codes 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

Hey guys,

var panWidth = $(".panContain").width();
var panImg = $(".panContain").find(".panImg");
var start = 50;
var width = panImg.width() - panWidth;
var tl = new TimelineMax({
  onComplete: function onComplete() {
    start = 0;
    tl.reverse();
  },
  onReverseComplete: function onReverseComplete() {
    start = 0;
    tl.restart();
  }
});
tl.fromTo(panImg, 20, {
  "transform": "translate("+ -start +"px,0)",
}, {
  "transform": "translate(-" + width + "px,0)",
  ease: Linear.easeNone
});

Please Help,

 

Here i want to set from value to "transform": "translate("+ -start +"px,0)" only when start. onComplete i want to tl.reverse() to "transform": "translate(0,0)" not 50 then again restart it from "transform": "translate(0,0)" not 50. Above my code does not reset start to 0 onComplete.

See the Pen jBqpxe by vishalbhulku (@vishalbhulku) on CodePen

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...