-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvisibility.js
More file actions
2 lines (2 loc) · 1.13 KB
/
visibility.js
File metadata and controls
2 lines (2 loc) · 1.13 KB
1
2
/*! Mini-utils 2014-02-06 */
var __hasProp={}.hasOwnProperty,__extends=function(a,b){function c(){this.constructor=a}for(var d in b)__hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};define(["./signal"],function(a){var b,c,d,e,f;return d=[],b=function(a){function b(a){this.view=a,b.__super__.constructor.apply(this,arguments)}return __extends(b,a),b.prototype.dispatch_if_visible=function(){return this.is_view_visible()?this.dispatch():void 0},b.prototype.is_view_visible=function(){var a;return a=this.view.getBoundingClientRect(),a.top<window.innerHeight&&a.bottom>0?!0:!1},b.prototype.add=function(a){return b.__super__.add.call(this,a),this.dispatch_if_visible()},b.prototype.addOnce=function(a){return b.__super__.addOnce.call(this,a),this.dispatch_if_visible()},b}(a),c=function(){return d.forEach(function(a){return a.dispatch_if_visible()})},e=function(a){var c;return c=new b(a),d.push(c),c},f=function(a){var b,c,e,f,g;for(g=[],b=e=0,f=d.length;f>e;b=++e){if(c=d[b],c.view===a){d.splice(b,1);break}g.push(void 0)}return g},window.addEventListener("scroll",c),{track_view:e,untrack_view:f}});