Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

white space/gap issue while sliding in custom content slider

Tags:

html

jquery

css

I am trying to make a custom content slider.Almost there, but having a issue with background white while scrolling.

There is a gap or space created between each slider.

I have created a fiddle so that you can view the slider.

<ul id="slider">
    <li class="case_study" id="case_study1">Div Slide 1 <div class="right"></div></li>
    <li class="case_study" id="case_study2">Div Slide 2 <div class="right"></div></li>
    <li class="case_study" id="case_study3">Div Slide 3 <div class="right"></div></li>
</ul>

Demo : http://jsfiddle.net/squidraj/6S6KT/2/

Full Screen : http://jsfiddle.net/squidraj/6S6KT/2/embedded/result/

Please suggest.

like image 716
user3671491 Avatar asked Dec 31 '25 06:12

user3671491


1 Answers

$('#slider li.case_study:first-child').animate({
    left: '-100%'
}, 300, function () { // The command function is a **CALLBACK**
    $('#slider li.case_study:first-child').css('left', '100%');

Your code above does what it is meant to do - I have added a comment where you are using a callback.

A callback fires when the first item has finished - so at the moment your script moves the first div 100% to the left THEN it adds the second div to the screen and animates it to the left.

You want everything to happen in your .animate({},300) clause - as follows:

Append second div to the right of first div - then move both divs to the left at the same time.

Have a go - if you get stuck then post your new code - but see if you can work it out yourself - it will help you learn faster!

like image 111
Graham Ritchie Avatar answered Jan 03 '26 08:01

Graham Ritchie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!