Created
January 11, 2012 12:54
-
-
Save lotsofcode/1594530 to your computer and use it in GitHub Desktop.
jquery plugin: check if a scrollbar has been scrolled 50% of overall height
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
$.fn.scrollCheck = function(options) { | |
var has_read_textarea = false; | |
textarea = $(this); | |
textarea.scroll(function() { | |
if ((textarea.scrollTop() + textarea.height()) >= (textarea[0].scrollHeight/2)) { | |
has_read_textarea = true; | |
} | |
}); | |
var textarea_timeout = window.setInterval(function() { | |
if (has_read_textarea !== false) { | |
window.clearTimeout(textarea_timeout); | |
if (options.doNext) { | |
options.doNext(); | |
} | |
} | |
}, options.timeout || 10000); | |
}; |
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
$("#test").scrollCheck({ | |
timeout: 100, | |
doNext: function() { | |
$('#continue').show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment