Share Posted February 27, 2015 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. index.html Link to comment Share on other sites More sharing options...
Share Posted February 27, 2015 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. https://css-tricks.c...-vs-javascript/ http://www.paulirish...posabs-topleft/ 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! 2 Link to comment Share on other sites More sharing options...
Author Share Posted February 27, 2015 Hi Jonathan, Thanks for your quick reply. I tried to change x 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 More sharing options...
Share Posted February 27, 2015 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 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now