Created
March 2, 2014 22:53
-
-
Save oak-tree/9315201 to your computer and use it in GitHub Desktop.
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
/** | |
* | |
* add bind to function prototype example | |
* model.on('click',myobject.somefunction.bind(this)); | |
* | |
*/ | |
Function.prototype.bind = function(context) { | |
var fn = this; // correlates to this.onTimeout | |
return function() { // what gets passed: an anonymous function | |
// when invoked, our original function, this.onTimeout, | |
// will have the proper context applied | |
return fn.apply(context, arguments); | |
} | |
} | |
var requestscrolling = false | |
$('element').on('touchmove',function(){ | |
onScroll(); | |
$('element').on('mousewheel',function(){ | |
onScroll(); | |
$('element').on('scroll',function(){ | |
onScroll(); | |
) | |
onScroll(){ | |
if (requestscrolling) | |
return; | |
requestscrolling =tru | |
setTimeout(infiniti,INT_TO_SCROLL) | |
} | |
infiniti(){ | |
// el is the element (jquery) | |
var elemTop = el.offset().top; | |
var elemBottom = elemTop + el.height(); | |
var pageBottom = $('body').scrollTop() + height + this.$el.offset().top; | |
var scrollTop = $('body').scrollTop() + $('body').height(); | |
if ((elemBottom - scrollTop) > INT_SCROLL_DISTANCE_TRIGGER) | |
return; | |
$.ajax({success:function(el.append(data))} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment