Created
October 30, 2012 22:38
-
-
Save XayOn/3983568 to your computer and use it in GitHub Desktop.
Automagically scroll down an image when you scroll to its half.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
($ document).ready -> | |
(($ document) .find '.showoff') .live 'mouseover', () -> | |
h = (($ this).css 'height').replace 'px', '' | |
($ document) .data 'next_position', ($ this).position().top + h + 20 | |
($ document) .data 'launch_position', ($ this).position().top + (h / 2) | |
($ document).live 'scroll', (event) -> | |
if ((Number) ($ document).scrollTop() > ((Number) (($ document) .data 'launch_position')) | |
window.scrollTo(0, ($ document).data 'next_position') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment