Jump to content

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

how to make scroll trigger work on mobile phones

Recommended Posts


this code work fine on pc when i am testing it  but  when i open  the code pen url in  my phone scroll trigger wont work and the   car wont move 

the question is this how can i make   the code work on phone 

I'm grateful for your kindness.


See the Pen wvqpGjq by alirezahekmati (@alirezahekmati) on CodePen

Link to comment
Share on other sites

Hello @alirezahekmati


It does work on mobile for me, but depending on the size of your screen the car might already have reached his endX and that's why you don't see it move. I adjusted the pen a bit, so now it runs from the left side off screen to the right side off screen, so now you should see it working, no matter how big the screen is.


let startX = gsap.getProperty('svg', 'width') * -1
let endX = width


.fromTo("svg", {x:startX}, {duration:duration, x:endX, ease:ease})


See the Pen bf350d6a1ddce94d54392d1f09a9c69b by akapowl (@akapowl) on CodePen


  • Like 4
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.