Jump to content
Search Community

Moving Element from right to left

sameermemon
Moderator Tag

Recommended Posts

sameermemon
Posted

Hi,

I have an element placed at right of the screen. I wanted to animate the element from right to its original position. Currently I am applying x property but it is animating the element from left to its original position.

gsap.png

Posted

Hey @sameermemon,

 

Welcome to the GreenSock Forum.

Without seeing your code it is difficult to understand your problem.

 

Here an example which could be helpful

 

See the Pen WNvELPE by mikeK (@mikeK) on CodePen.

 

Happy tweening ...

Mikel

  • Like 1
sameermemon
Posted

Thanks for the quick solution Mikel.

 

 I used below code to solve the issue -

 

gsap.fromTo("#box",{
        x :  50,
        opacity : 0
    }, {
        x : 0,
        opacity : 1
    }); 

Let me know, if it is valid one.

Posted

Hey @sameermemon,

 

Your code looks fine.

 

Be aware of the defaults of duration and ease if that is a point:

duration The duration of the animation (in seconds). Default: 0.5

 

ease Controls the rate of change during the animation, giving it a specific feel. Default: "power1.out"

 

Happy tweening ...

Mikel

 

  • Like 1
ZachSaucier
Posted
5 hours ago, sameermemon said:

I used below code to solve the issue -

 

gsap.fromTo("#box",{
        x :  50,
        opacity : 0
    }, {
        x : 0,
        opacity : 1
    }); 

Let me know, if it is valid one.

It is valid, but you can just use a .from() tween like Mikel's demo and it'd be simpler :) 

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