size-sensor 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,6 +105,7 @@ Used By:
105
105
 
106
106
  - [hustcc/echarts-for-react](https://github.com/hustcc/echarts-for-react)
107
107
  - [hustcc/canvas-nest.js](https://github.com/hustcc/canvas-nest.js)
108
+ - [hustcc/gantt-for-react](https://github.com/hustcc/gantt-for-react)
108
109
 
109
110
 
110
111
 
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.sizeSensor={})}(this,function(e){"use strict";var t=1,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=null;return function(){for(var i=this,o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];clearTimeout(n),n=setTimeout(function(){e.apply(i,r)},t)}},i="undefined"!=typeof ResizeObserver?function(e){var t=void 0,i=[],o=n(function(){i.forEach(function(t){t(e)})}),r=function(){t.disconnect(),i=[],t=void 0};return{element:e,bind:function(n){t||(t=function(){var t=new ResizeObserver(o);return t.observe(e),o(),t}()),-1===i.indexOf(n)&&i.push(n)},destroy:r,unbind:function(e){var n=i.indexOf(e);-1!==n&&i.splice(n,1),0===i.length&&t&&r()}}}:function(e){var t=void 0,i=[],o=n(function(){i.forEach(function(t){t(e)})}),r=function(){t&&t.parentNode&&(t.contentDocument.defaultView.removeEventListener("resize",o),t.parentNode.removeChild(t),t=void 0,i=[])};return{element:e,bind:function(n){t||(t=function(){"static"===getComputedStyle(e).position&&(e.style.position="relative");var t=document.createElement("object");return t.onload=function(){t.contentDocument.defaultView.addEventListener("resize",o),o()},t.setAttribute("style","display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;opacity:0"),t.setAttribute("class","size-sensor-object"),t.type="text/html",e.appendChild(t),t.data="about:blank",t}()),-1===i.indexOf(n)&&i.push(n)},destroy:r,unbind:function(e){var n=i.indexOf(e);-1!==n&&i.splice(n,1),0===i.length&&t&&r()}}},o={},r=function(e){var n=e.getAttribute("size-sensor-id");if(n&&o[n])return o[n];var r=""+t++;e.setAttribute("size-sensor-id",r);var u=i(e);return o[r]=u,u};e.bind=function(e,t){var n=r(e);return n.bind(t),function(){n.unbind(t)}},e.clear=function(e){!function(e){var t=e.element.getAttribute("size-sensor-id");e.element.removeAttribute("size-sensor-id"),e.destroy(),t&&o[t]&&delete o[t]}(r(e))},Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.sizeSensor={})}(this,function(e){"use strict";var t=1,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=null;return function(){for(var i=this,o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];clearTimeout(n),n=setTimeout(function(){e.apply(i,r)},t)}},i="undefined"!=typeof ResizeObserver?function(e){var t=void 0,i=[],o=n(function(){i.forEach(function(t){t(e)})}),r=function(){t.disconnect(),i=[],t=void 0};return{element:e,bind:function(n){t||(t=function(){var t=new ResizeObserver(o);return t.observe(e),o(),t}()),-1===i.indexOf(n)&&i.push(n)},destroy:r,unbind:function(e){var n=i.indexOf(e);-1!==n&&i.splice(n,1),0===i.length&&t&&r()}}}:function(e){var t=void 0,i=[],o=n(function(){i.forEach(function(t){t(e)})}),r=function(){t&&t.parentNode&&(t.contentDocument&&t.contentDocument.defaultView.removeEventListener("resize",o),t.parentNode.removeChild(t),t=void 0,i=[])};return{element:e,bind:function(n){t||(t=function(){"static"===getComputedStyle(e).position&&(e.style.position="relative");var t=document.createElement("object");return t.onload=function(){t.contentDocument.defaultView.addEventListener("resize",o),o()},t.setAttribute("style","display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;opacity:0"),t.setAttribute("class","size-sensor-object"),t.type="text/html",e.appendChild(t),t.data="about:blank",t}()),-1===i.indexOf(n)&&i.push(n)},destroy:r,unbind:function(e){var n=i.indexOf(e);-1!==n&&i.splice(n,1),0===i.length&&t&&r()}}},o={},r=function(e){var n=e.getAttribute("size-sensor-id");if(n&&o[n])return o[n];var r=""+t++;e.setAttribute("size-sensor-id",r);var u=i(e);return o[r]=u,u};e.bind=function(e,t){var n=r(e);return n.bind(t),function(){n.unbind(t)}},e.clear=function(e){!function(e){var t=e.element.getAttribute("size-sensor-id");e.element.removeAttribute("size-sensor-id"),e.destroy(),t&&o[t]&&delete o[t]}(r(e))},Object.defineProperty(e,"__esModule",{value:!0})});
@@ -81,8 +81,10 @@ var createSensor = exports.createSensor = function createSensor(element) {
81
81
  */
82
82
  var destroy = function destroy() {
83
83
  if (sensor && sensor.parentNode) {
84
- // 移除事件
85
- sensor.contentDocument.defaultView.removeEventListener('resize', resizeListener);
84
+ if (sensor.contentDocument) {
85
+ // 移除事件
86
+ sensor.contentDocument.defaultView.removeEventListener('resize', resizeListener);
87
+ }
86
88
  // 移除 dom
87
89
  sensor.parentNode.removeChild(sensor);
88
90
  // 初始化
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "size-sensor",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "DOM element size sensor which will callback when size changed.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {