Jquery slider: horizontal image slider

ben ben

This is my first post in stackoverflow and I am beginning in JQuery programming too. I was trying to make my own Jquery image slider and I want the image to slider from right to left but the image kept slider from the top left corner I couldn't nkow why?

Here is the fiddle http://jsfiddle.net/rAqcP/193/

my css is:

.slider {
width:100%;
height:400px;
overflow:hidden;
background-image:url("http://test.softvex.com/Slider/Img/loading.gif");
background-repeat:no-repeat;
background-position:center;}
    .slider img {
    width:100%;
    height:400px;
    display:none;
}

My JS is:

$(document).ready(function() {

$('.slider #1').show({right:'0'}, 500);
$('.slider #1').delay(5500).hide('slide', 'linear', 500);

var sliderTotalImg = $('.slider img').size();
var counterIndex = 2;

setInterval(function () {
    $('.slider #' + counterIndex).show({right:'0'}, 500);
    $('.slider #' + counterIndex).delay(5500).hide('slide', 'linear', 500);

    if (counterIndex == sliderTotalImg) {
        //reset counter
        counterIndex = 1;
    }
    else {
        counterIndex = counterIndex + 1;
    }
},6500);});

and lastly my markup

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<div class = "slider">
 <img id="1" src="http://test.softvex.com/Slider/Img/photography/001.jpg"/>
 <img id="2" src="http://test.softvex.com/Slider/Img/photography/003.jpg"/>
</div>

Thanks for helping

Robert

if i understand you right then just make show slide just like the hide

$(document).ready(function() {

//$('.slider #1').show({right:'0'}, 500);
$('.slider #1').show('slide', 'linear', 500);
$('.slider #1').delay(5500).hide('slide', 'linear', 500);

var sliderTotalImg = $('.slider img').size();
var counterIndex = 2;

setInterval(function () {
    //$('.slider #' + counterIndex).show({right:'0'}, 500);
    $('.slider #' + counterIndex).show('slide', 'linear', 500);
    $('.slider #' + counterIndex).delay(5500).hide('slide', 'linear', 500);

    if (counterIndex == sliderTotalImg) {
        //reset counter
        counterIndex = 1;
    }
    else {
        counterIndex = counterIndex + 1;
    }
},6500);});

try here http://jsfiddle.net/rAqcP/198/

if this is not what you leave comment and say you exactly what you want

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related