我目前使用下面的JavaScript,如下圖所示的圖像毛刺。 它的工作很好,當我把在div .image_scroll_3在短短的文字,但只要我插入圖像的滾動和毛刺不會移過圖像的頂部。無限滾動的div與
任何建議,將不勝感激
JS
<script>
(function($, undefined) {
$.fn.loopScroll = function(p_options) {
var options = $.extend({
direction: "upwards",
speed: 60
}, p_options);
return this.each(function() {
var obj = $(this).find(".image_scroll_2");
var text_height = obj.find(".image_scroll_3").height();
var start_y, end_y;
if (options.direction == "downwards") {
start_y = -text_height;
end_y = 0;
} else if (options.direction == "upwards") {
start_y = 0;
end_y = -text_height;
}
var animate = function() {
// setup animation of specified block "obj"
// calculate distance of animation
var distance = Math.abs(end_y - parseInt(obj.css("top")));
//alert("animate " + obj.css("top") + "-> " + end_y + " " + distance);
//duration will be distance/speed
obj.animate(
{ top: end_y }, //scroll upwards
1500 * distance/options.speed,
"linear",
function() {
// scroll to start position
obj.css("top", start_y);
animate();
}
);
};
obj.find(".image_scroll_3").clone().appendTo(obj);
$(this).on("mouseout", function() {
obj.stop();
}).on("mouseout", function() {
animate(); // resume animation
});
obj.css("top", start_y);
animate(); // start animation
});
};
}(jQuery));
$("#example4").loopScroll({ speed: 700 });
</script>
您可以創建一個小提琴嗎?很難想象如果沒有真正看到它的實際問題可能會出現什麼問題。 –
@TahirAhmed不用擔心,這裏是[鏈接](http://jsfiddle.net/qw8zr6xm) –
*毛刺*是相當不明顯的,你不覺得嗎?任何特定的環境/設置使它看起來更加突出? –