-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscrollceptor.js
More file actions
2 lines (2 loc) · 814 Bytes
/
scrollceptor.js
File metadata and controls
2 lines (2 loc) · 814 Bytes
1
2
/*! Mini-utils 2014-02-06 */
define(["./signal"],function(a){var b,c,d;return c=[],d=function(a){var b,c,d,e,f,g,h,i,j;return j=a.target,d=a.options,i=a.status,b=j.getBoundingClientRect(),"x"===d.axis?(g=j.scrollLeft,h=j.scrollWidth,c=j.offsetWidth,e=g/(h-c)):"y"===d.axis&&(e=-b.top/(b.height-window.innerHeight)),f=d.from<e&&e<d.to,f!==i?(a.status=f,f?a.viewportInsideRange.dispatch():a.viewportOutsideRange.dispatch()):void 0},window.addEventListener("scroll",function(){return c.forEach(d)}),b=function(){function b(b,e){var f,g=this;this.target=b,this.options=e,this.viewportInsideRange=new a,this.viewportOutsideRange=new a,this.status=null,(f=this.options).axis||(f.axis="y"),"y"===this.options.axis?c.push(this):this.target.addEventListener("scroll",function(){return d(g)})}return b}(),{Scrollceptor:b}});