구현하고자하는 이미지 스크롤러가 있습니다. 이미지 스크롤은 작동하지만 수평 대신 수직으로 이동합니다. 여기에 지금까지 무엇을 가지고 있습니다 :Jquery 이미지 스크롤러가 다음 이미지로 전환하지 않습니다.
<a href = "#" id = "btnNext">Next Image</a>
$('#btnNext').click(function() {
//Calls new image with value true, meaning next image
newImage(true);
return false;
});
function newImage(direction) {
//Get the current selected item (with selected class), if none was found, get the first item
current_image = $('#imageGallery li.selected').length ? $('#imageGallery li.selected') : $('#imageGallery li:first');
//If determines slideshow direction
if (direction) { //Next image
//Get next sibling
next_image = (current_image.next().length) ? current_image.next() : $('#imageGallery li:first');
} else { //Previous image
//Get previous sibling
next_image = (current_image.prev().length) ? current_image.prev() : $('#imageGallery li:last');
}
//Clear selected class
$('#imageGallery li').removeClass('selected');
//Reassign selected class to current image
next_image.addClass('selected');
//Scroll images
$('#images').scrollTo(next_image, 800);
}
업데이트 : 여기 내 quesions 있습니다 1) 어떻게이 그것을 수평으로 이동하기 위해 수정합니까이? 2) .scrollTo()를 사용하지 않고 이와 같은 이미지 스크롤러를 만드는 방법이 있습니까?
도움 주셔서 감사합니다. 그 덕분에 대부분의 작업이 가능해졌습니다. 첫 번째 선택으로 돌아가도록 코드를 편집하는 방법을 알고 있습니까? –
죄송합니다, 이것을 놓쳤습니다. 이를 수행하는 한 가지 방법은 현재 보여주고있는 사진을 추적하고 끝까지 도달 한 후 다시 시작하는 것입니다. http://jsfiddle.net/meloncholy/KzBzT/20/ – meloncholy
분명히 이것이 이상적인 것은 아닙니다. 예를 들어, 갤러리를 멈추려면 브라우저의 크기에 따라 마지막 세 장이 남았을 것입니다. 갤러리가 고정 폭이면 하드 코딩하거나 outerWidth() + 여백을 사용하여 남겨 둘 사진 수를 계산할 수 있습니다. – meloncholy