.
http://jsbin.com/paqim/4/edit 당신은 멋진 무한한 슬라이더를 가지고 있습니다.
HTML :
<div id="page">
<div id="swatches">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<button id="prev">◀</button>
<button id="next">▶</button>
</div>
JQ :
var $s = $("#swatches"),
$b = $('#prev, #next'),
$d = function(fl){return $('>div',$s)[fl]();},
px = 260; // Animation px
$s.prepend($d('last')).scrollLeft(px); // Prepend last + reset pos to '1'.
$b.click(function() {
if(!$s.is(':animated')){
if(this.id=="next") $s.animate({scrollLeft:px*2}, 400, function() {
$s.scrollLeft(px).append($d('first'));
});
else $s.prepend($d('last')).scrollLeft(px*2).animate({scrollLeft:px}, 400);
}
});
당신이 몇 가지 코드를 게시하시기 바랍니다 수 있습니까? SO에 관한 질문은 앞으로 다른 방문자들에게도 도움이 될 것입니다. –
내 코드를 게시 할 수 없습니다. JS 바이올린에서 링크가 작동하지 않습니다. 내가 도대체 뭘 잘못하고있는 겁니까? –