Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Timothy Recker
12,086 PointsScrolling Carousel using jQuery Animate
I'm trying to make an image carousel/slider that automatically scrolls smoothly and loops using jQuery.
Here's an illustration: https://jsfiddle.net/T_Recks/aa43n7g0/
I tried adding it to a local development site (replacing the text and colored backgrounds with images) and it seems to work nicely. However, I'd like to make a version that scrolls right instead of left, but haven't been able to figure it out. I've tried changing ".append" to ".prepend" and playing with the margin changes, but no luck so far.
Is there anyone here familiar with javascript/jQuery that's able to suggest a solution?
2 Answers
Graeme Oxley
8,931 Points"marginLeft: 200" instead of "-200" makes it go right.
It doesn't quite work right after that, but you can alter that now that it's going the right direction.
Timothy Recker
12,086 PointsFor the curious, I asked the question on stackoverflow as well and someone responded with this solution, which I'm happy with: https://jsfiddle.net/T_Recks/fdxgq3fr/
Timothy Recker
12,086 PointsTimothy Recker
12,086 PointsThanks for the response! Yeah, I did technically manage to make it to move right by doing that, but it breaks the looping functionality and that's the point I'm stuck at (should have clarified).