Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
179
rated 0 times [  181] [ 2]  / answers: 1 / hits: 16240  / 12 Years ago, sun, october 21, 2012, 12:00:00

Here is a working example of horizontal scroll with mousewheel, but it does not scroll smoothly. By smoothly I mean like ordinary vertical scroll in Firefox or Opera.



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


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



I've made a live demo to demonstrate this.
http://jsfiddle.net/Dw4Aj/



I want this scroll to work like the vertical one, both with mousewheel and smoothness.



Can someone help me?


More From » jquery

 Answers
169

I'm just going to leave this here.



http://jsfiddle.net/Dw4Aj/19/



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

});

[#82445] Friday, October 19, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
domeniccolti

Total Points: 276
Total Questions: 98
Total Answers: 93

Location: India
Member since Fri, May 13, 2022
2 Years ago
domeniccolti questions
Mon, Oct 18, 21, 00:00, 3 Years ago
Thu, Oct 14, 21, 00:00, 3 Years ago
Thu, Jul 15, 21, 00:00, 3 Years ago
Sat, Oct 24, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;