Skip to content

Instantly share code, notes, and snippets.

@oak-tree
Created March 2, 2014 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oak-tree/9315201 to your computer and use it in GitHub Desktop.
Save oak-tree/9315201 to your computer and use it in GitHub Desktop.
/**
*
* 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