define(["jquery","underscore"],function(e,t){var n,r;return r={threshold:.75},n=function(n,r){var i=this;return this.element=e(n),this.options=r,r.relative?this.height=this.element.find(r.relative).innerHeight()-this.element.innerHeight():this.height=this.element.innerHeight(),this.threshold=this.height*r.threshold,this.element.on("scroll",t.debounce(function(){if(!i.reached&&i.element.scrollTop()>=i.threshold)return i.reached=!0,i.element.trigger("scroller")},50)),r.trigger&&this.element.on("scroller",r.trigger),this},n.prototype={constructor:n,reset:function(){return this.reached=!1,this.options.relative?this.height=this.element.find(this.options.relative).innerHeight()-this.element.innerHeight():this.height=this.element.innerHeight(),this.threshold=this.height*this.options.threshold,this}},e.fn.scroller=function(t){var i;return e.isPlainObject(t)?i=e.extend({},t,r):i=e.extend({},r),this.each(function(){var r,s;r=e(this),s=r.data("scroller"),s||r.data("scroller",s=new n(this,i));if(typeof t=="string")return s[t]()})},e.fn.scroller.Constructor=n})