我似乎遇到懸停邊緣滾動解決方案的一些麻煩,我已經有一個拖動滾動實施。jQuery無限/連續滾動懸停
這裏是我的代碼:
演示1(當前頁):http://jsfiddle.net/SO_AMK/FdLZJ/
演示2(我試了一下):http://jsfiddle.net/SO_AMK/8CCeA/
HTML摘錄:
<section class="row">
<div class="scroll-left" style="opacity: 0;"></div>
<div class="row-scroll">
<div class="tile">
<img class="tile-image" src="http://cache.gawker.com/assets/images/lifehacker/2011/08/1030-macpack-notational-velocity.jpg" />
<title class="tile-title">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...</title>
</div>
.....
<div class="tile">
<img class="tile-image" src="http://cache.gawker.com/assets/images/lifehacker/2011/08/1030-macpack-notational-velocity.jpg" />
<title class="tile-title">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...</title>
</div>
</div>
<div class="scroll-right" style="opacity: 0;"></div>
</section>
<section class="row">
<div class="scroll-left" style="opacity: 0;"></div>
<div class="row-scroll">
<div class="tile">
<img class="tile-image" src="http://cache.gawker.com/assets/images/lifehacker/2011/08/1030-macpack-notational-velocity.jpg" />
<title class="tile-title">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...</title>
</div>
.....
<div class="tile">
<img class="tile-image" src="http://cache.gawker.com/assets/images/lifehacker/2011/08/1030-macpack-notational-velocity.jpg" />
<title class="tile-title">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...</title>
</div>
</div>
<div class="scroll-right" style="opacity: 0;"></div>
</section>
jQuery的:
$(document).ready(function() {
var pos = 5;
$.fn.loopingScroll = function (direction, scrollElement) {
if (direction == "right") {
pos+=5;
}
else if (direction == "left") {
pos-=5;
}
$(scrollElement).parent().scrollLeft($(scrollElement).parent().data('scrollLeft') + pos);
return this;
}
$(".scroll-left").hover(function(){
scrollLeftLoop = setInterval(function(){
$(this).loopingScroll("left", this);
}, 25);
$(this).fadeIn('fast');
}, function() { clearInterval(scrollLeftLoop); $(this).fadeOut('fast'); });
$(".scroll-right").hover(function(){
scrollRightLoop = setInterval(function(){
$(this).loopingScroll("right", this);
}, 25);
$(this).fadeIn('fast');
}, function() { clearInterval(scrollRightLoop); $(this).fadeOut('fast'); });
});
這是假設(去!)是脈衝替代/ WebApp,因此設計(我正在處理字體)。
任何想法?
預先感謝您。
+1 for fiddle'http:// jsfiddle.net/FdLZJ/20 /' – 2014-06-13 18:45:05