function myMarquee(box) { var box = $(box) var slider = box.find('.slider') var li = slider.find('li') var prev = box.find('.prev') var next = box.find('.next') var bHeight = box.outerHeight() var tHeight = slider.outerHeight() + 10 if (tHeight > bHeight) { box.addClass('isScroll') setTimeout(function() { var tClone = li.clone(true) slider.append(tClone) }, 1000) var topValue = 0 var timer function Marquee() { timer = setInterval(function() { if (Math.abs(topValue) >= tHeight) { topValue = topValue + tHeight } slider.css({ top: topValue-- }) }, 20) } Marquee() box.mouseenter(function() { clearInterval(timer) }) box.mouseleave(function() { Marquee() }) prev.click(function() { if (topValue + 100 <= 0) { topValue += 100 } else { topValue = 0 } slider.stop().animate({ top: topValue }, 500) }) next.click(function() { if (Math.abs(topValue - 100) >= tHeight * 2 - bHeight) { topValue = bHeight - tHeight * 2 } else { topValue -= 100 } slider.stop().animate({ // top: topValue - 100, top: topValue }, 500) // topValue -= 100 }) } else { box.removeClass('isScroll') } } function mySlider(box) { var box = $(box) var slider = box.find('.slider') var li = slider.find('li') var prev = box.find('.prev') var next = box.find('.next') box.addClass('isScroll') prev.click(function() { var active = slider.find('.active') var currentIndex = active.index() if (currentIndex > 0) { var currentTop = active.position().top var currentHeight = active.prev().outerHeight() + 10 var topValue = currentTop - currentHeight slider.stop().animate({ top: -topValue }, 1000, function() { li.eq(currentIndex - 1).addClass('active').siblings().removeClass('active') }) } }) next.click(function() { var active = slider.find('.active') var currentIndex = active.index() var currentTop = active.position().top var currentHeight = active.outerHeight() + 10 var boxHeight = box.outerHeight() var slideHeight = slider.outerHeight() var topValue = currentTop + currentHeight if (topValue + boxHeight > slideHeight) { slider.stop().animate({ top: boxHeight - slideHeight }, 1000) } else { slider.stop().animate({ top: -topValue }, 1000, function() { li.eq(currentIndex + 1).addClass('active').siblings().removeClass('active') }) } }) } function ajax(url, id) { var ajax = $.ajax({ url: url, async: false, data: { id: id } }); $("#list-show").html(ajax.responseText); }; function ajaxVal(url, id, val) { var ajax = $.ajax({ url: url, async: false, data: { id: id, val: val } }); // $('.ajax-search input').val(''); $("#list-show").html(ajax.responseText); };