0

Hello guys can you help me with my problem? I have a list of maps in my page. In every page there is 40 different maps. So in order to view the last map I need to hold down the mouse and scroll horizontally to the right to view this. But how can I do this using scrolling down/up of the mouse?

I am a beginner in jquery/javascript that's why I don't have an idea how to do this.

Here's my sample html code.

<div id="horizontal">
<table border="1">
    <tr>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
        <td>
            <img src="http://localhost/img1.jpg" height="300" widt="300" />
        </td>
    </tr>
</table>
</div>
...
var $horizontal = $('#horizontal');

$(window).scroll(function () {
     //how to detect the scrolling of the mouse?
});

Ont more question. Where should I place the div tag horizontal? Is it in the tag? or tag? Ok that's all. Here's my sample fiddle. http://jsfiddle.net/rochellecanale/A3UHf/

Jerielle
  • 7,144
  • 29
  • 98
  • 164

2 Answers2

4

You need Brandon Aaron's jquery plugin to trigger horizontal scrolling with mousewheel

http://jsfiddle.net/A3UHf/5/

$("body").mousewheel(function(event, delta) {
    this.scrollLeft -= (delta * 30);
    event.preventDefault();
});
thenewseattle
  • 1,451
  • 1
  • 13
  • 17
3

You could use the mousewheel plugin. scrolling horizontally with the mousewheel should then work with this code:

$("body").mousewheel(function(event, delta) {

    this.scrollLeft -= (delta * 30);

    event.preventDefault();

});
kave
  • 461
  • 1
  • 6
  • 17