-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize-observer.min.js
executable file
·5 lines (5 loc) · 1.87 KB
/
size-observer.min.js
1
2
3
4
5
/*! size-observer v1.0 | ©2012-2018 GestiXi | Licensed under the MIT license */
!function(c){var g=[],f=0,l,h;c.fn.onResize=function(a,b){var d=c.type(a);"function"===d?(b=a,a=["height","width"]):"string"===d&&(a=[a]);if("function"===c.type(b))return this.each(function(){var d=c(this),e=d.data("onResize");e?(e.addProperties(a),e.handlers.push(b)):(e=new k(this,a,b),d.data("onResize",e))})};var k=function(a,b,c){this.element=a;this.handlers=[c];this.addProperties(b);g.push(this);p(this)};c.fn.onResize.Constructor=k;k.prototype={constructor:k,addProperties:function(a){this.properties=
c.unique(c.merge(this.properties||[],a));this.check=this.sizeCheckFunction(this.properties)},sizeCheckFunction:function(a){var b=this.element,d=[];if(b===window){var f=[document.documentElement];var e={height:"clientHeight",width:"clientWidth"}}else b===document?(f=[document.body,document.documentElement],e={height:["clientHeight","scrollHeight","offsetHeight"],width:["clientWidth","scrollWidth","offsetWidth"]}):(f=[b],e={height:"clientHeight",width:"clientWidth",top:"offsetTop",left:"offsetLeft",
bottom:"offsetBottom",right:"offsetRight"},-1===c.inArray("left",a)&&-1===c.inArray("offsetLeft",a)||e.push({t:b,k:"offsetLeft"}));for(b=a.length-1;0<=b;b--)for(var k=a[b],g=f.length-1;0<=g;g--){var l=f[g],m;if(m=e[k]){"array"!==c.type(m)&&(m=[m]);for(var h=m.length-1;0<=h;h--)d.push({t:l,k:m[h]})}else d.push({t:l,k:k})}return function(){for(var a="",b=d.length-1;0<=b;b--){var c=d[b];a+=c.t[c.k]+"-"}return this.size!==a?a:!1}}};var p=function(a){h=a.check();if(!1!==h){if(a.hasOwnProperty("size"))for(var b=
a.handlers.length-1;0<=b;b--)a.handlers[b].call(a.element,a);a.size=h}},q=function(){for(var a=g.length-1;0<=a;a--)p(g[a]);l=setTimeout(q,10>f?64:100>f?250:1E3);f++},n=function(){l&&clearTimeout(l);f=0;q()};n();c(window).on("resize",function(){n()});c(window).on("scroll",function(){n()})}(window.jQuery);