#horiz
将是我想将粗体代码应用于的任何通用标记。我使用jScrollPane和jQuery MouseWheel库。我需要将以下鼠标滚轮事件转换为可调用函数
$("#horiz").mousewheel(function(event, delta) {
**event.preventDefault();
$(this).find(".jspPane").animate({"left": "+=" + (50 * delta) + "px"}, 0);
$(this).find(".jspPane").css("left").replace(/[^-\d\.]/g, '') > 0 ? $(this).find(".jspPane").animate({"left": "0px"}, 0) : null;
$(this).find(".jspPane").css("left").replace(/[^-\d\.]/g, '') < (($(this).find("#scrollText").css("width").replace(/[^-\d\.]/g, '') - $(this).css("width").replace(/[^-\d\.]/g, '')) * -1) ? $(this).find(".jspPane").animate({"left": (($(this).find("#scrollText").css("width").replace(/[^-\d\.]/g, '') - $(this).css("width").replace(/[^-\d\.]/g, '')) * -1) + "px"}, 0) : null;
if($(this).find(".jspTrack").css("width").replace(/[^-\d\.]/g, '') - $(this).find(".jspDrag").css("width").replace(/[^-\d\.]/g, '') == $(this).find(".jspDrag").css("left").replace(/[^-\d\.]/g, '')) {
//Track End - Right
} else if ($(this).find(".jspDrag").css("left").replace(/[^-\d\.]/g, '') == 0) {
//Track End - Left
} else {
//Track Mid - Anywhere between ends
}**
});
我认为这将是最好的策略。出于某种原因,下面创建的功能打破了可滚动性:/谢谢! – Matt