简体   繁体   中英

trying to make carousel animation slider

i am trying to creat a carousel animation that take 3 pics and slide the to the left and bring new 3 images, i don't think i'm in the right direction need help

here is the fiddle link: http://jsfiddle.net/G5cKK/11/

setInterval(function () {
   $('img:first').animate({
        'left': -$('.box').width() + 'px'
    },1000,  function () {
            $(this).remove().appendTo('.all')
    });
}, 5000);

You can animate width instead of position:

JavaScript

setInterval(function() {  
   var $img = $('img:first');
   var $imgClone = $img.clone().width(0).appendTo('.all');

   $img.animate({'width': 0},1000, function(){$img.remove()});
   $imgClone.animate({'width': 65},1000);
}, 5000)    

Demo: http://jsfiddle.net/G5cKK/12/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM