Reputation: 7827
I am creating my own custom content slider and am wondering what the best way to go about it is using jQuery.
I want to have two buttons next/previous. When the user clicks next the current slide will slide to the left and the new slide will show.
How should I go about doing this in jQuery? I would use a plugin but they are so annoying when it comes to customization.
Code so far:
<!--Main slider content-->
<div class="contentslider_content" style=" float:left; width:890px; height:300px; border:1px solid #CCC; overflow:hidden;">
<div class="contentslider_slides slide_1" style=" float:left; width:890px; height:300px; background-color:#0F3"></div>
<div class="contentslider_slides slide_2" style=" float:left; width:890px; height:300px; background-color:#ccc"></div>
<div class="contentslider_slides slide_3" style=" float:left; width:890px; height:300px; background-color:#ccc"></div>
</div>
<!--Main slider content-->
<button class="next">Next</button>
<button class="previous">Previous</button>
Upvotes: 1
Views: 348
Reputation: 30996
This is my approach: http://jsfiddle.net/UpDcS/3/
What i am doing is (basically): All items are hidden by default and positioned absolutely in the viewport. I created two functions that wrap the logic of getting the next/previous element in the slideshow so it can be scrolled endlessly. The sliding is achieved by setting the new item to the left/right of the current item and moving both items by 100% to that side. After this, the (now) old item is hidden again. I hope you can figure out the details. This should be a pretty good starting point.
Upvotes: 1
Reputation: 3164
My answer is not about the JQ code itself - it's about the concept.
I made something similar myself by:
And, as for customization.. it's almost 'style-free', just css it.
Hope I understood your question and it's answering it. Yossi
Upvotes: 0