element-resize-detector
Advanced tools
Comparing version 0.3.4 to 0.3.5
/*! | ||
* element-resize-detector 0.3.4 (2015-09-21, 12:38) | ||
* element-resize-detector 0.3.5 (2015-09-28, 16:48) | ||
* https://github.com/wnr/element-resize-detector | ||
@@ -391,5 +391,8 @@ * Licensed under MIT | ||
// Store the size of the element sync here, so that multiple scroll events may be ignored in the event listeners. | ||
// Otherwise the if-check in handleScroll is useless. | ||
storeCurrentSize(element, width, height); | ||
batchProcessor.add(function updateDetectorElements() { | ||
updateChildSizes(element, width, height); | ||
storeCurrentSize(element, width, height); | ||
}); | ||
@@ -403,22 +406,17 @@ | ||
var expand = getExpandElement(element); | ||
var shrink = getShrinkElement(element); | ||
addEvent(expand, "scroll", function onExpand() { | ||
function handleScroll() { | ||
var style = getComputedStyle(element); | ||
var width = parseSize(style.width); | ||
var height = parseSize(style.height); | ||
if (width > element.lastWidth || height > element.lastHeight) { | ||
if (width !== element.lastWidth || height !== element.lastHeight) { | ||
changed(); | ||
} | ||
}); | ||
} | ||
addEvent(shrink, "scroll", function onShrink() { | ||
var style = getComputedStyle(element); | ||
var width = parseSize(style.width); | ||
var height = parseSize(style.height); | ||
if (width < element.lastWidth || height < element.lastHeight) { | ||
changed(); | ||
} | ||
}); | ||
var expand = getExpandElement(element); | ||
var shrink = getShrinkElement(element); | ||
addEvent(expand, "scroll", handleScroll); | ||
addEvent(shrink, "scroll", handleScroll); | ||
} | ||
@@ -425,0 +423,0 @@ |
/*! | ||
* element-resize-detector 0.3.4 (2015-09-21, 12:38) | ||
* element-resize-detector 0.3.5 (2015-09-28, 16:48) | ||
* https://github.com/wnr/element-resize-detector | ||
@@ -7,2 +7,2 @@ * Licensed under MIT | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.elementResizeDetectorMaker=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=a("./utils");b.exports=function(a){function b(a,b){b||(b=a,a=0),a>o?o=a:p>a&&(p=a),m[a]||(m[a]=[]),l&&k&&0===n&&f(),m[a].push(b),n++}function c(a){void 0===a&&(a=k),q&&(h(q),q=null),k?f():e()}function e(){for(var a=p;o>=a;a++)for(var b=m[a],c=0;c<b.length;c++){var d=b[c];d()}g()}function f(){q=i(e)}function g(){m={},n=0,o=0,p=0}function h(a){var b=window.clearTimeout;return b(a)}function i(a){var b=function(a){return window.setTimeout(a,0)};return b(a)}a=a||{};var j=a.reporter,k=d.getOption(a,"async",!0),l=d.getOption(a,"auto",!0);l&&!k&&(j&&j.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),k=!0);var m,n,o,p;g();var q;return{add:b,force:c}}},{"./utils":2}],2:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=b.exports={};e.getOption=d},{}],3:[function(a,b,c){"use strict";var d=b.exports={};d.isIE=function(a){function b(){var a=navigator.userAgent.toLowerCase();return-1!==a.indexOf("msie")||-1!==a.indexOf("trident")}if(!b())return!1;if(!a)return!0;var c=function(){var a,b=3,c=document.createElement("div"),d=c.getElementsByTagName("i");do c.innerHTML="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->";while(d[0]);return b>4?b:a}();return a===c},d.isLegacyOpera=function(){return!!window.opera}},{}],4:[function(a,b,c){"use strict";var d=b.exports={};d.forEach=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c]);if(d)return d}}},{}],5:[function(a,b,c){"use strict";var d=a("../browser-detector");b.exports=function(a){function b(a,b){function c(){b(a)}if(!e(a))throw new Error("Element is not detectable by this strategy.");if(d.isIE(8))a.attachEvent("onresize",c);else{var f=e(a);f.contentDocument.defaultView.addEventListener("resize",c)}}function c(a,b){function c(a,b){function c(){function c(a,b){return a.contentDocument?void b(a.contentDocument):void setTimeout(function(){c(a,b)},100)}var d=this;c(d,function(c){b(a)})}function e(){if("static"===j){a.style.position="relative";var b=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};b(f,a,i,"top"),b(f,a,i,"right"),b(f,a,i,"bottom"),b(f,a,i,"left")}var e=document.createElement("object");e.style.cssText=h,e.type="text/html",e.onload=c,d.isIE()||(e.data="about:blank"),a.appendChild(e),a._erdObject=e,d.isIE()&&(e.data="about:blank")}var h="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",i=getComputedStyle(a),j=i.position;g?g.add(e):e()}d.isIE(8)?b(a):c(a,b)}function e(a){return a._erdObject}a=a||{};var f=a.reporter,g=a.batchProcessor;if(!f)throw new Error("Missing required dependency: reporter.");return{makeDetectable:c,addListener:b}}},{"../browser-detector":3}],6:[function(a,b,c){"use strict";b.exports=function(a){function b(a,b){var c=function(){var c=getComputedStyle(a),d=n(c.width),e=n(c.height);q.add(function(){i(a,d,e),j(a,d,e)}),q.add(1,function(){k(a,d,e),b(a)})},e=d(a),g=f(a);l(e,"scroll",function(){var b=getComputedStyle(a),d=n(b.width),e=n(b.height);(d>a.lastWidth||e>a.lastHeight)&&c()}),l(g,"scroll",function(){var b=getComputedStyle(a),d=n(b.width),e=n(b.height);(d<a.lastWidth||e<a.lastHeight)&&c()})}function c(a,b){function c(){w&&x&&y&&b(a)}function d(){function b(a,b,c,d){return a=a?a+"px":"0",b=b?b+"px":"0",c=c?c+"px":"0",d=d?d+"px":"0","position: absolute; left: "+a+"; top: "+b+"; right: "+d+"; bottom: "+c+"; overflow: scroll; z-index: -1; visibility: hidden;"}if("static"===g){a.style.position="relative";var d=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}"auto"!==c&&"0"!==e(c)&&(a.warn("An element that is positioned static has style."+d+"="+c+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};d(p,a,s,"top"),d(p,a,t,"right"),d(p,a,u,"bottom"),d(p,a,v,"left")}var e=r.width,f=r.height,j=b(-1,-1,-f,-e),k=b(0,0,-f,-e),n="position: absolute; left: 0; top: 0;",q=document.createElement("div"),y=document.createElement("div"),z=document.createElement("div"),A=document.createElement("div"),B=document.createElement("div");q.style.cssText=j,y.style.cssText=k,z.style.cssText=n,A.style.cssText=k,B.style.cssText=n+" width: 200%; height: 200%;",y.appendChild(z),A.appendChild(B),q.appendChild(y),q.appendChild(A),a.appendChild(q),a._erdElement=q,l(y,"scroll",function C(){m(y,"scroll",C),w=!0,c()}),l(A,"scroll",function D(){m(A,"scroll",D),x=!0,c()}),i(a,h,o)}function e(){j(a,h,o),k(a,h,o),y=!0,c()}var f=getComputedStyle(a),g=f.position,h=n(f.width),o=n(f.height),s=f.top,t=f.right,u=f.bottom,v=f.left,w=!1,x=!1,y=!1;q?(q.add(d),q.add(1,e)):(d(),e())}function d(a){return a._erdElement.childNodes[0]}function e(a){return d(a).childNodes[0]}function f(a){return a._erdElement.childNodes[1]}function g(a){return a+10}function h(a){return 2*a}function i(a,b,c){var d=e(a),f=g(b),h=g(c);d.style.width=f+"px",d.style.height=h+"px"}function j(a,b,c){a.lastWidth=b,a.lastHeight=c}function k(a,b,c){var e=d(a),i=f(a),j=g(b),k=g(c),l=h(b),m=h(c);e.scrollLeft=j,e.scrollTop=k,i.scrollLeft=l,i.scrollTop=m}function l(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c)}function m(a,b,c){a.attachEvent?a.detachEvent("on"+b,c):a.removeEventListener(b,c)}function n(a){return parseFloat(a.replace(/px/,""))}function o(){var a=500,b=500,c=document.createElement("div");c.style.cssText="position: absolute; width: "+2*a+"px; height: "+2*b+"px; visibility: hidden;";var d=document.createElement("div");d.style.cssText="position: absolute; width: "+a+"px; height: "+b+"px; overflow: scroll; visibility: none; top: "+3*-a+"px; left: "+3*-b+"px; visibility: hidden;",d.appendChild(c),document.body.insertBefore(d,document.body.firstChild);var e=a-d.clientWidth,f=b-d.clientHeight;return document.body.removeChild(d),{width:e,height:f}}a=a||{};var p=a.reporter,q=a.batchProcessor;if(!p)throw new Error("Missing required dependency: reporter.");var r=o();return{makeDetectable:c,addListener:b}}},{}],7:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=a("./collection-utils").forEach,f=a("./element-utils"),g=a("./listener-handler"),h=a("./id-generator"),i=a("./id-handler"),j=a("./reporter"),k=a("./browser-detector"),l=a("batch-processor"),m=a("./detection-strategy/object.js"),n=a("./detection-strategy/scroll.js");b.exports=function(a){function b(a,b,f){function g(a){var b=v.get(a);e(b,function(b){b(a)})}function h(a,b,c){v.add(b,c),a&&c(b)}if(f||(f=b,b=a,a={}),!b)throw new Error("At least one element required.");if(!f)throw new Error("Listener required.");void 0===b.length&&(b=[b]);var i=0,j=d(a,"callOnAdd",t.callOnAdd),k=d(a,"onReady",function(){});e(b,function(a){var d=c.get(a);return w.isDetectable(a)?(h(j,a,f),void i++):w.isBusy(a)?(h(j,a,f),z[d]=z[d]||[],void z[d].push(function(){i++,i===b.length&&k()})):(w.markBusy(a,!0),u.makeDetectable(a,function(a){w.markAsDetectable(a),w.markBusy(a,!1),u.addListener(a,g),h(j,a,f),i++,i===b.length&&k(),z[d]&&(e(z[d],function(a){a()}),delete z[d])}))}),i===b.length&&k()}a=a||{};var c=a.idHandler;if(!c){var o=h(),p=i(o);c=p}var q=a.reporter;if(!q){var r=q===!1;q=j(r)}var s=d(a,"batchProcessor",l({reporter:q})),t={};t.callOnAdd=!!d(a,"callOnAdd",!0);var u,v=g(c),w=f(),x=d(a,"strategy","object"),y={reporter:q,batchProcessor:s};if("scroll"===x&&k.isLegacyOpera()&&(q.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),x="object"),"scroll"===x)u=n(y);else{if("object"!==x)throw new Error("Invalid strategy name: "+x);u=m(y)}var z={};return{listenTo:b}}},{"./browser-detector":3,"./collection-utils":4,"./detection-strategy/object.js":5,"./detection-strategy/scroll.js":6,"./element-utils":8,"./id-generator":9,"./id-handler":10,"./listener-handler":11,"./reporter":12,"batch-processor":1}],8:[function(a,b,c){"use strict";b.exports=function(){function a(a){return!!a._erdIsDetectable}function b(a){a._erdIsDetectable=!0}function c(a){return!!a._erdBusy}function d(a,b){a._erdBusy=!!b}return{isDetectable:a,markAsDetectable:b,isBusy:c,markBusy:d}}},{}],9:[function(a,b,c){"use strict";b.exports=function(){function a(){return b++}var b=1;return{generate:a}}},{}],10:[function(a,b,c){"use strict";b.exports=function(a){function b(a,b){return b||d(a)||c(a),a[e]}function c(b){var c=a.generate();return b[e]=c,c}function d(a){return void 0!==a[e]}var e="_erdTargetId";return{get:b}}},{}],11:[function(a,b,c){"use strict";b.exports=function(a){function b(b){return d[a.get(b)]}function c(b,c){var e=a.get(b);d[e]||(d[e]=[]),d[e].push(c)}var d={};return{get:b,add:c}}},{}],12:[function(a,b,c){"use strict";b.exports=function(a){function b(){}var c={log:b,warn:b,error:b};if(!a&&window.console){var d=function(a,b){a[b]=function(){console[b].apply(console,arguments)}};d(c,"log"),d(c,"warn"),d(c,"error")}return c}},{}]},{},[7])(7)}); | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.elementResizeDetectorMaker=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=a("./utils");b.exports=function(a){function b(a,b){b||(b=a,a=0),a>o?o=a:p>a&&(p=a),m[a]||(m[a]=[]),l&&k&&0===n&&f(),m[a].push(b),n++}function c(a){void 0===a&&(a=k),q&&(h(q),q=null),k?f():e()}function e(){for(var a=p;o>=a;a++)for(var b=m[a],c=0;c<b.length;c++){var d=b[c];d()}g()}function f(){q=i(e)}function g(){m={},n=0,o=0,p=0}function h(a){var b=window.clearTimeout;return b(a)}function i(a){var b=function(a){return window.setTimeout(a,0)};return b(a)}a=a||{};var j=a.reporter,k=d.getOption(a,"async",!0),l=d.getOption(a,"auto",!0);l&&!k&&(j&&j.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),k=!0);var m,n,o,p;g();var q;return{add:b,force:c}}},{"./utils":2}],2:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=b.exports={};e.getOption=d},{}],3:[function(a,b,c){"use strict";var d=b.exports={};d.isIE=function(a){function b(){var a=navigator.userAgent.toLowerCase();return-1!==a.indexOf("msie")||-1!==a.indexOf("trident")}if(!b())return!1;if(!a)return!0;var c=function(){var a,b=3,c=document.createElement("div"),d=c.getElementsByTagName("i");do c.innerHTML="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->";while(d[0]);return b>4?b:a}();return a===c},d.isLegacyOpera=function(){return!!window.opera}},{}],4:[function(a,b,c){"use strict";var d=b.exports={};d.forEach=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c]);if(d)return d}}},{}],5:[function(a,b,c){"use strict";var d=a("../browser-detector");b.exports=function(a){function b(a,b){function c(){b(a)}if(!e(a))throw new Error("Element is not detectable by this strategy.");if(d.isIE(8))a.attachEvent("onresize",c);else{var f=e(a);f.contentDocument.defaultView.addEventListener("resize",c)}}function c(a,b){function c(a,b){function c(){function c(a,b){return a.contentDocument?void b(a.contentDocument):void setTimeout(function(){c(a,b)},100)}var d=this;c(d,function(c){b(a)})}function e(){if("static"===j){a.style.position="relative";var b=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};b(f,a,i,"top"),b(f,a,i,"right"),b(f,a,i,"bottom"),b(f,a,i,"left")}var e=document.createElement("object");e.style.cssText=h,e.type="text/html",e.onload=c,d.isIE()||(e.data="about:blank"),a.appendChild(e),a._erdObject=e,d.isIE()&&(e.data="about:blank")}var h="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",i=getComputedStyle(a),j=i.position;g?g.add(e):e()}d.isIE(8)?b(a):c(a,b)}function e(a){return a._erdObject}a=a||{};var f=a.reporter,g=a.batchProcessor;if(!f)throw new Error("Missing required dependency: reporter.");return{makeDetectable:c,addListener:b}}},{"../browser-detector":3}],6:[function(a,b,c){"use strict";b.exports=function(a){function b(a,b){function c(){var b=getComputedStyle(a),c=n(b.width),d=n(b.height);(c!==a.lastWidth||d!==a.lastHeight)&&e()}var e=function(){var c=getComputedStyle(a),d=n(c.width),e=n(c.height);j(a,d,e),q.add(function(){i(a,d,e)}),q.add(1,function(){k(a,d,e),b(a)})},g=d(a),h=f(a);l(g,"scroll",c),l(h,"scroll",c)}function c(a,b){function c(){w&&x&&y&&b(a)}function d(){function b(a,b,c,d){return a=a?a+"px":"0",b=b?b+"px":"0",c=c?c+"px":"0",d=d?d+"px":"0","position: absolute; left: "+a+"; top: "+b+"; right: "+d+"; bottom: "+c+"; overflow: scroll; z-index: -1; visibility: hidden;"}if("static"===g){a.style.position="relative";var d=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}"auto"!==c&&"0"!==e(c)&&(a.warn("An element that is positioned static has style."+d+"="+c+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};d(p,a,s,"top"),d(p,a,t,"right"),d(p,a,u,"bottom"),d(p,a,v,"left")}var e=r.width,f=r.height,j=b(-1,-1,-f,-e),k=b(0,0,-f,-e),n="position: absolute; left: 0; top: 0;",q=document.createElement("div"),y=document.createElement("div"),z=document.createElement("div"),A=document.createElement("div"),B=document.createElement("div");q.style.cssText=j,y.style.cssText=k,z.style.cssText=n,A.style.cssText=k,B.style.cssText=n+" width: 200%; height: 200%;",y.appendChild(z),A.appendChild(B),q.appendChild(y),q.appendChild(A),a.appendChild(q),a._erdElement=q,l(y,"scroll",function C(){m(y,"scroll",C),w=!0,c()}),l(A,"scroll",function D(){m(A,"scroll",D),x=!0,c()}),i(a,h,o)}function e(){j(a,h,o),k(a,h,o),y=!0,c()}var f=getComputedStyle(a),g=f.position,h=n(f.width),o=n(f.height),s=f.top,t=f.right,u=f.bottom,v=f.left,w=!1,x=!1,y=!1;q?(q.add(d),q.add(1,e)):(d(),e())}function d(a){return a._erdElement.childNodes[0]}function e(a){return d(a).childNodes[0]}function f(a){return a._erdElement.childNodes[1]}function g(a){return a+10}function h(a){return 2*a}function i(a,b,c){var d=e(a),f=g(b),h=g(c);d.style.width=f+"px",d.style.height=h+"px"}function j(a,b,c){a.lastWidth=b,a.lastHeight=c}function k(a,b,c){var e=d(a),i=f(a),j=g(b),k=g(c),l=h(b),m=h(c);e.scrollLeft=j,e.scrollTop=k,i.scrollLeft=l,i.scrollTop=m}function l(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c)}function m(a,b,c){a.attachEvent?a.detachEvent("on"+b,c):a.removeEventListener(b,c)}function n(a){return parseFloat(a.replace(/px/,""))}function o(){var a=500,b=500,c=document.createElement("div");c.style.cssText="position: absolute; width: "+2*a+"px; height: "+2*b+"px; visibility: hidden;";var d=document.createElement("div");d.style.cssText="position: absolute; width: "+a+"px; height: "+b+"px; overflow: scroll; visibility: none; top: "+3*-a+"px; left: "+3*-b+"px; visibility: hidden;",d.appendChild(c),document.body.insertBefore(d,document.body.firstChild);var e=a-d.clientWidth,f=b-d.clientHeight;return document.body.removeChild(d),{width:e,height:f}}a=a||{};var p=a.reporter,q=a.batchProcessor;if(!p)throw new Error("Missing required dependency: reporter.");var r=o();return{makeDetectable:c,addListener:b}}},{}],7:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=a("./collection-utils").forEach,f=a("./element-utils"),g=a("./listener-handler"),h=a("./id-generator"),i=a("./id-handler"),j=a("./reporter"),k=a("./browser-detector"),l=a("batch-processor"),m=a("./detection-strategy/object.js"),n=a("./detection-strategy/scroll.js");b.exports=function(a){function b(a,b,f){function g(a){var b=v.get(a);e(b,function(b){b(a)})}function h(a,b,c){v.add(b,c),a&&c(b)}if(f||(f=b,b=a,a={}),!b)throw new Error("At least one element required.");if(!f)throw new Error("Listener required.");void 0===b.length&&(b=[b]);var i=0,j=d(a,"callOnAdd",t.callOnAdd),k=d(a,"onReady",function(){});e(b,function(a){var d=c.get(a);return w.isDetectable(a)?(h(j,a,f),void i++):w.isBusy(a)?(h(j,a,f),z[d]=z[d]||[],void z[d].push(function(){i++,i===b.length&&k()})):(w.markBusy(a,!0),u.makeDetectable(a,function(a){w.markAsDetectable(a),w.markBusy(a,!1),u.addListener(a,g),h(j,a,f),i++,i===b.length&&k(),z[d]&&(e(z[d],function(a){a()}),delete z[d])}))}),i===b.length&&k()}a=a||{};var c=a.idHandler;if(!c){var o=h(),p=i(o);c=p}var q=a.reporter;if(!q){var r=q===!1;q=j(r)}var s=d(a,"batchProcessor",l({reporter:q})),t={};t.callOnAdd=!!d(a,"callOnAdd",!0);var u,v=g(c),w=f(),x=d(a,"strategy","object"),y={reporter:q,batchProcessor:s};if("scroll"===x&&k.isLegacyOpera()&&(q.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),x="object"),"scroll"===x)u=n(y);else{if("object"!==x)throw new Error("Invalid strategy name: "+x);u=m(y)}var z={};return{listenTo:b}}},{"./browser-detector":3,"./collection-utils":4,"./detection-strategy/object.js":5,"./detection-strategy/scroll.js":6,"./element-utils":8,"./id-generator":9,"./id-handler":10,"./listener-handler":11,"./reporter":12,"batch-processor":1}],8:[function(a,b,c){"use strict";b.exports=function(){function a(a){return!!a._erdIsDetectable}function b(a){a._erdIsDetectable=!0}function c(a){return!!a._erdBusy}function d(a,b){a._erdBusy=!!b}return{isDetectable:a,markAsDetectable:b,isBusy:c,markBusy:d}}},{}],9:[function(a,b,c){"use strict";b.exports=function(){function a(){return b++}var b=1;return{generate:a}}},{}],10:[function(a,b,c){"use strict";b.exports=function(a){function b(a,b){return b||d(a)||c(a),a[e]}function c(b){var c=a.generate();return b[e]=c,c}function d(a){return void 0!==a[e]}var e="_erdTargetId";return{get:b}}},{}],11:[function(a,b,c){"use strict";b.exports=function(a){function b(b){return d[a.get(b)]}function c(b,c){var e=a.get(b);d[e]||(d[e]=[]),d[e].push(c)}var d={};return{get:b,add:c}}},{}],12:[function(a,b,c){"use strict";b.exports=function(a){function b(){}var c={log:b,warn:b,error:b};if(!a&&window.console){var d=function(a,b){a[b]=function(){console[b].apply(console,arguments)}};d(c,"log"),d(c,"warn"),d(c,"error")}return c}},{}]},{},[7])(7)}); |
{ | ||
"name": "element-resize-detector", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "resize event emitter for elements.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/wnr/element-resize-detector", |
@@ -32,5 +32,8 @@ /** | ||
// Store the size of the element sync here, so that multiple scroll events may be ignored in the event listeners. | ||
// Otherwise the if-check in handleScroll is useless. | ||
storeCurrentSize(element, width, height); | ||
batchProcessor.add(function updateDetectorElements() { | ||
updateChildSizes(element, width, height); | ||
storeCurrentSize(element, width, height); | ||
}); | ||
@@ -44,22 +47,17 @@ | ||
var expand = getExpandElement(element); | ||
var shrink = getShrinkElement(element); | ||
addEvent(expand, "scroll", function onExpand() { | ||
function handleScroll() { | ||
var style = getComputedStyle(element); | ||
var width = parseSize(style.width); | ||
var height = parseSize(style.height); | ||
if (width > element.lastWidth || height > element.lastHeight) { | ||
if (width !== element.lastWidth || height !== element.lastHeight) { | ||
changed(); | ||
} | ||
}); | ||
} | ||
addEvent(shrink, "scroll", function onShrink() { | ||
var style = getComputedStyle(element); | ||
var width = parseSize(style.width); | ||
var height = parseSize(style.height); | ||
if (width < element.lastWidth || height < element.lastHeight) { | ||
changed(); | ||
} | ||
}); | ||
var expand = getExpandElement(element); | ||
var shrink = getShrinkElement(element); | ||
addEvent(expand, "scroll", handleScroll); | ||
addEvent(shrink, "scroll", handleScroll); | ||
} | ||
@@ -66,0 +64,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
230457
3659