/
jquery.fixedoverflow.js
24 lines (24 loc) · 1 KB
/
jquery.fixedoverflow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
* jQuery Fixed Overflow
* http://www.andrewdeniszczyc.com/
* Copyright 2012, Andrew Deniszczyc
*/
(function($){
$.fn.fixedOverflow = function(options) {
return this.each(function(){
var $this = $(this);
$this.bind("touchstart", function() {
// Check that the element has actually overflowed, and check if at the top
if ($this.prop("scrollHeight") > $this.innerHeight() && $this.scrollTop() == 0) {
// Scroll element down 1 causing scroll bounce
$this.scrollTop(1);
}
// Check that the element has actually overflowed, and check if at the bottom
else if ($this.prop("scrollHeight") > $this.innerHeight() && ($this.prop("scrollHeight") - $this.scrollTop()) <= $this.outerHeight()) {
// Scroll element up 1 causing scroll bounce
$this.scrollTop($this.scrollTop()-1);
}
});
});
};
})(jQuery);