forked from protonet/jquery.inview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.inview.min.js
More file actions
1 lines (1 loc) · 1.45 KB
/
jquery.inview.min.js
File metadata and controls
1 lines (1 loc) · 1.45 KB
1
!function(t){function e(){var e,i,n={height:d.innerHeight,width:d.innerWidth};return n.height||(e=f.compatMode,(e||!t.support.boxModel)&&(i="CSS1Compat"===e?r:f.body,n={height:i.clientHeight,width:i.clientWidth})),n}function i(){return{top:d.pageYOffset||r.scrollTop||f.body.scrollTop,left:d.pageXOffset||r.scrollLeft||f.body.scrollLeft}}function n(){var n,l=[],f=0;if(t.each(a,function(t,e){var i=e.data.selector,n=e.$element;l.push(i?n.find(i):n)}),n=l.length)for(o=o||e(),h=h||i();n>f;f++)if(t.contains(r,l[f][0])){var d,c,s,p=t(l[f]),u={height:p.height(),width:p.width()},g=p.offset(),v=p.data("inview"),w=void 0===p.data("offset")?0:p.data("offset");if(!h||!o)return;g.top+u.height+w>h.top&&g.top<h.top+o.height+w&&g.left+u.width+w>h.left&&g.left<h.left+o.width+w?(d=h.left>g.left+w?"right":h.left+o.width<g.left+u.width+w?"left":"both",c=h.top>g.top+w?"bottom":h.top+o.height<g.top+u.height+w?"top":"both",s=d+"-"+c,v&&v===s||p.data("inview",s).trigger("inview",[!0,d,c])):v&&p.data("inview",!1).trigger("inview",[!1])}}var o,h,l,a={},f=document,d=window,r=f.documentElement,c=t.expando;t.event.special.inview={add:function(e){a[e.guid+"-"+this[c]]={data:e,$element:t(this)},l||t.isEmptyObject(a)||(l=setInterval(n,250))},remove:function(e){try{delete a[e.guid+"-"+this[c]]}catch(i){}t.isEmptyObject(a)&&(clearInterval(l),l=null)}},t(d).bind("scroll resize scrollstop",function(){o=h=null}),!r.addEventListener&&r.attachEvent&&r.attachEvent("onfocusin",function(){h=null})}(jQuery);