2

Good day.

I need script that will follow the mouse and will scroll content depending on what side mouse is. If left then left, if right then right.

I need it for cases when line of hrefs will exceed width of block, like here http://cloud.ignatynikulin.com/45121918090s3R15193i

If the width is exceed then you will be able to scroll it when you put your mouse to right.

Something that will do that: http://codecanyon.net/item/jquery-mouse-slider/full_screen_preview/143061

I tried that script, but the problem with it is that it needs to rely on some width that I don't have.

Any plugin or ideas suggestion?

Thank you!

Ignaty Nikulin
  • 143
  • 2
  • 2
  • 6
  • Just from a user's perspective, that effect is *really* annoying. – Blender Sep 13 '11 at 15:15
  • It depends, I have only 500px in height and I can not afford to loose that space. – Ignaty Nikulin Sep 13 '11 at 15:18
  • That's a bit more sane. That image gallery was quite hard to look at... – Blender Sep 13 '11 at 15:21
  • Its just a demo how it should work, I will not use it for images, and big scrolling things.I just need to avoid things like this http://cloud.ignatynikulin.com/1T05023y3u2V3Z2T1O3o because I don't have space to make everything higher that one line. And I am not arguing or something like that. I really appreciate your point of view and support it. But it is how it is. I want effect that is used by google on mobile devices. http://cloud.ignatynikulin.com/2F221b0O1J3y1W2R1b0w – Ignaty Nikulin Sep 13 '11 at 15:23
  • Another way of achieving this is to actually scroll the content proportionally to the position of the mouse in the visible container. Like this : http://www.comptoirdescotonniers.com/fra/newsletter.aspx?zoom=1 – tsimbalar Sep 14 '11 at 11:27
  • @tsimbalar exactly what I wanted! Thank you! But if width of main container is dynamically changeable? – Ignaty Nikulin Sep 14 '11 at 14:10
  • @Ignaty then you have to recompute a few things each time the size of the contents changes ... (on document ready, on image loaded in browsers like Chrome ... ) you can quite easily access that size with jQuery – tsimbalar Sep 14 '11 at 14:45

2 Answers2

1

Check out the answer here from StackOverflow - it's a perfect solution:

Continuous scroll on hover [performance]

Community
  • 1
  • 1
Dave Hilditch
  • 5,299
  • 4
  • 27
  • 35
-1

Make the containing div positioned absolute. Then in jQuery, catch the onMouseMove event, calculate the mouse position relative to the containing div (using .width() this works even with dynamic width), and change the left/right property of your containing div according to this.

Reference: jQuery get mouse position within an element

Community
  • 1
  • 1
Praxis Ashelin
  • 5,137
  • 2
  • 20
  • 46