Vladimir Wood Vladimir Wood - 1 year ago 91
jQuery Question

Smooth horizontal scroll bound to mousewheel

Here is working example of horizontal scroll with mousewheel, but it do not scroll smoothly, like ordinary vertical scroll in Firefox or Opera.

$(function() {
$("html, body").mousewheel(function(event, delta) {
this.scrollLeft -= (delta * 30);

( http://brandonaaron.net/code/mousewheel/docs )

I've made the live demo to show you how it's occur.

I want this scroll to work like the vertical one. Both with mousewheel and smoothness. Can someone help me?

Answer Source

I'm just going to leave this here.


jQuery(document).ready(function($) {
$("html, body").mousewheel(function(e, delta) { 
    $('html, body').stop().animate({scrollLeft: '-='+(150*delta)+'px' }, 200, 'easeOutQuint');