我正在使用图书馆:https://code.google.com/p/jquery-nicescroll/downloads/detail?name=jquery.nicescroll.340.zip&can=2&q=
虽然我似乎能够使用像jQuery的scrollLeft
等喜欢的事件,但nicescroll打破了中间点击和滚动功能,这本身并不是那么糟糕,但表明其他未知行为也可能被打破了。
是否有用于实现漂亮滚动条的库/方法,但具有本机功能?
答案 0 :(得分:0)
脱离我的头顶
var MIDDLE_CLICK = 2;
var clicking = [];
var moveInterval = undefined;
var lastY = undefined;
$("#nicely_scrolled_element").mousedown(function(e){
clicking[e.which] = true
startY = lastY = e.pageY;
// default behavior is every so often scroll the page
// we base it on how far they were last from the start
moveInterval = setInterval(function(){
$el = $('#nicely_scrolled_element');
$el.scrollTop($el.scrollTop() + lastY - startY);
}, 500);
})
// they may mouse up elsewhere so we use window this time
$(window).mouseup(function(e){
clicking[e.which] = false
clearInterval(moveInterval);
})
// remember where they moved to
$(window).mousemove(function(e){
if(clicking[MIDDLE_CLICK]){
lastY = e.pageY;
}
})
这是未经测试的,我刚写完了。它应该工作吗?