Brian Battenfeld
Brian Battenfeld

Reputation: 69

gallery/div slide based on cursor position

I'm looking for a solution to animate a horizontal gallery (div) based on cursor's proximity to the left or right of the window. The center of the window will do nothing, but as you begin to creep left, the gallery slides right, and visa versa. Very common thing to do, but I want to accomplish this with javascript/jquery. If someone could just get me on the right track I would appreciate it.

Upvotes: 1

Views: 3214

Answers (2)

Roko C. Buljan
Roko C. Buljan

Reputation: 206058

(Edit) For a newer and improved example go to this SO question:
Horizontal scroll on mouseMove - wide div in smaller div with overflow:hidden (Can't get the math to work)


I created a mousemove gallery. Hope this will help.

JSFIDDLE DEMO: MOUSEMOVE GALLERY

Just set into the css the desired width and height of the gallery container.
Fill the gallery with images and enjoy! :)
The code is simplyfied and commented to help anyone upgrade it.

Upvotes: 2

Related Questions