mirror of
https://github.com/medialab-prado/datamad2017.git
synced 2024-12-27 05:01:23 +01:00
1 line
1.2 KiB
JavaScript
1 line
1.2 KiB
JavaScript
|
!function(t){t.fn.appear=function(e,s){var o=t.extend({data:void 0,one:!0,accX:0,accY:0},s);return this.each(function(){var s=t(this);if(s.appeared=!1,!e)return void s.trigger("appear",o.data);var i=t(window),a=function(){if(!s.is(":visible"))return void(s.appeared=!1);var t=i.scrollLeft(),e=i.scrollTop(),a=s.offset(),r=a.left,n=a.top,p=o.accX,u=o.accY,c=s.height(),h=i.height(),l=s.width(),f=i.width();e>n+c+u||n>e+h+u||t>r+l+p||r>t+f+p?s.appeared=!1:s.appeared||s.trigger("appear",o.data)},r=function(){if(s.appeared=!0,o.one){i.unbind("scroll",a);var r=t.inArray(a,t.fn.appear.checks);0>r||t.fn.appear.checks.splice(r,1)}e.apply(this,arguments)};o.one?s.one("appear",o.data,r):s.bind("appear",o.data,r),i.scroll(a),t.fn.appear.checks.push(a),a()})},t.extend(t.fn.appear,{checks:[],timeout:null,checkAll:function(){var e=t.fn.appear.checks.length;if(e>0)for(;e--;)t.fn.appear.checks[e]()},run:function(){t.fn.appear.timeout&&clearTimeout(t.fn.appear.timeout),t.fn.appear.timeout=setTimeout(t.fn.appear.checkAll,20)}}),t.each(["append","prepend","after","before","attr","removeAttr","addClass","removeClass","toggleClass","remove","css","show","hide"],function(e,s){var o=t.fn[s];o&&(t.fn[s]=function(){var e=o.apply(this,arguments);return t.fn.appear.run(),e})})}(jQuery);
|