he reescrito el código de la respuesta por Anónimo @-lechuga. El cálculo de ancho del elemento se salta porque no era necesario y, a veces, no era deseable. Esto también proporciona una función adicional para pasar scroll-amount
en px
al complemento.
utilizar de esta manera:
$(document).ready(function(){
$('#your_div').hScroll(100); // You can pass (optionally) scrolling amount
});
aquí va el plugin actualizado jquery.hscroll.js
:
jQuery(function ($) {
$.fn.hScroll = function (amount) {
amount = amount || 120;
$(this).bind("DOMMouseScroll mousewheel", function (event) {
var oEvent = event.originalEvent,
direction = oEvent.detail ? oEvent.detail * -amount : oEvent.wheelDelta,
position = $(this).scrollLeft();
position += direction > 0 ? -amount : amount;
$(this).scrollLeft(position);
event.preventDefault();
})
};
});
Aquí está la versión miniaturizada de la misma jquery.hscroll.min.js
:
jQuery(function(e){e.fn.hScroll=function(l){l=l||120,e(this).bind("DOMMouseScroll mousewheel",function(t){var i=t.originalEvent,n=i.detail?i.detail*-l:i.wheelDelta,o=e(this).scrollLeft();o+=n>0?-l:l,e(this).scrollLeft(o),t.preventDefault()})}});
Aquí es el JSFiddle
nos muestran lo que usted ha intentado –