Jump to content


GSAP Slider Too Slow on Mobile + Image Not Visible on Slide Start

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

Hello All,


In my attached file, I have tried to modify a simple slider as per my requirement. But, when I slide the slider, the target image gets displayed only after slide animation is finished. Can someone help?


Also on mobile, it is sliding very slowly. Please help.


I have attached my file for your reference.


Link to comment
Share on other sites

Hello krishe, and Welcome to the GreenSock Forum!


It looks like you are animating very large images.. 1920x1080 .. you might want to resize the images to fit your slider width and height. And each image is like 1.6mb. I would optimize your images so they still look good but have a smaller file size.


Also what device are you seeing this on mobile? Is it android or and apple device?


You could try changing the CSS property left to x:


var fg = document.getElementById("fg");
    var one = document.getElementById("one");
    var two = document.getElementById("two");
    var three = document.getElementById("three");

one.addEventListener("click", function() {
      TweenLite.to(fg, 1.5, {css:{x: "0px"}});

two.addEventListener("click", function() {
      TweenLite.to(fg, 1.5, {css:{x: "-726px"}});

three.addEventListener("click", function() {
      TweenLite.to(fg, 1.5, {css:{x: "-1452px"}});


The reason its better to animate x over left is that the CSS left property does not animate on a sub-pixel level, only on a pixel level ( -726px ) .  But animating x property with GSAP you will be animating on a sub-pixel level ( -726.64858px ) .. which will make for a smoother animation.


You can learn more about why animating x and y are better than animating left and top.





Does that help? .. if not.. please create a codepen demo so we can test your code live in an editable environment.


Here is a video tut on how to create a codepen demo example.


Thanks! :)

  • Like 2
Link to comment
Share on other sites

Hi Jonathan,


Thanks for your quick reply. I tried to change property, but it does not show subsequent images. Also, can you please let me know why the image is visible only after animation is finished?


Here is the Codepen demo.

See the Pen ogypje by krishie (@krishie) on CodePen

Link to comment
Share on other sites

Your css had some issues.

Take overflow:hidden off of .shell and you will see the images are stacking vertically, not aligned in a row horizontally.


here is a quick edit: http://codepen.io/GreenSock/pen/jEKYqg

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