1 line
656 B
JavaScript
1 line
656 B
JavaScript
|
!function(i){i.add("module","visibility",{init:function(i,t){this.app=i,this.$win=i.$win;var s={tolerance:15};this.context=t,this.params=t.getParams(s),this.$element=t.getElement()},start:function(){this.$win.on("scroll.kube.visibility resize.kube.visibility",this._check.bind(this)),this._check()},stop:function(){this.$win.off(".kube.visibility")},_check:function(){var i=this.$win.scrollTop(),t=i+this.$win.height(),s=this.$element.offset().top,e=s+this.$element.height(),n=e>=i&&t>=s&&e<=t+this.params.tolerance&&s>=i;n?this.app.broadcast("visibility.visible",this,this.$element):this.app.broadcast("visibility.invisible",this,this.$element)}})}(Kube);
|