Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

reverse change var value

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;
  onReverseComplete: function onReverseComplete() {
    start = 0;
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.