resizelistener
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -47,3 +47,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
eval("var el = document.getElementById('demo')\nvar resize = __webpack_require__(1)\n\nvar unbind = resize(el, function (e) {\n console.log(e)\n})\n\ndocument.getElementById('unbind').addEventListener('click', function () {\n unbind()\n})\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUvaW5kZXguanM/M2RhZCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZWwgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnZGVtbycpXG52YXIgcmVzaXplID0gcmVxdWlyZSgnLi4nKVxuXG52YXIgdW5iaW5kID0gcmVzaXplKGVsLCBmdW5jdGlvbiAoZSkge1xuICBjb25zb2xlLmxvZyhlKVxufSlcblxuZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ3VuYmluZCcpLmFkZEV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xuICB1bmJpbmQoKVxufSlcblxuXG5cbi8qKioqKioqKioqKioqKioqKlxuICoqIFdFQlBBQ0sgRk9PVEVSXG4gKiogLi9leGFtcGxlL2luZGV4LmpzXG4gKiogbW9kdWxlIGlkID0gMFxuICoqIG1vZHVsZSBjaHVua3MgPSAwXG4gKiovIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0="); | ||
eval("var el = document.getElementById('demo')\nvar resize = __webpack_require__(1)\n\nvar unbind = resize(el, function (e) {\n console.log(e)\n})\n\ndocument.getElementById('unbind').addEventListener('click', function () {\n unbind()\n})\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUvaW5kZXguanM/M2RhZCJdLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgZWwgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnZGVtbycpXG52YXIgcmVzaXplID0gcmVxdWlyZSgnLi4nKVxuXG52YXIgdW5iaW5kID0gcmVzaXplKGVsLCBmdW5jdGlvbiAoZSkge1xuICBjb25zb2xlLmxvZyhlKVxufSlcblxuZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ3VuYmluZCcpLmFkZEV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgZnVuY3Rpb24gKCkge1xuICB1bmJpbmQoKVxufSlcblxuXG5cbi8qKioqKioqKioqKioqKioqKlxuICoqIFdFQlBBQ0sgRk9PVEVSXG4gKiogLi9leGFtcGxlL2luZGV4LmpzXG4gKiogbW9kdWxlIGlkID0gMFxuICoqIG1vZHVsZSBjaHVua3MgPSAwXG4gKiovIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0="); | ||
@@ -54,11 +54,23 @@ /***/ }, | ||
eval("var attachEvent = document.attachEvent\nvar raf = __webpack_require__(2)\n\nvar cancelFrame = (function(){\n var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame ||\n window.clearTimeout\n return function(id){ return cancel(id); }\n})()\n\nfunction resizeListener(e){\n var win = e.target || e.srcElement\n if (win.__resizeRAF__) cancelFrame(win.__resizeRAF__)\n win.__resizeRAF__ = raf(function(){\n var trigger = win.__resizeTrigger__\n trigger.__resizeListeners__.forEach(function(fn){\n fn.call(trigger, e)\n })\n })\n}\n\nfunction objectLoad(e){\n this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__\n this.contentDocument.defaultView.addEventListener('resize', resizeListener)\n}\n\nfunction removeListener (element, fn) {\n element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1)\n if (!element.__resizeListeners__.length) {\n if (attachEvent) element.detachEvent('onresize', resizeListener)\n else {\n element.__resizeTrigger__.contentDocument.defaultView.removeEventListener('resize', resizeListener)\n element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__)\n }\n }\n}\nmodule.exports = function(element, fn){\n if (!element.__resizeListeners__) {\n element.__resizeListeners__ = []\n if (attachEvent) {\n element.__resizeTrigger__ = element\n element.attachEvent('onresize', resizeListener)\n }\n else {\n if (getComputedStyle(element).position == 'static') element.style.position = 'relative'\n var obj = element.__resizeTrigger__ = document.createElement('object');\n obj.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;')\n obj.__resizeElement__ = element\n obj.onload = objectLoad\n obj.type = 'text/html'\n obj.data = 'about:blank'\n element.appendChild(obj)\n }\n }\n element.__resizeListeners__.push(fn)\n return removeListener.bind(null, element, fn)\n}\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9pbmRleC5qcz85NTUyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBhdHRhY2hFdmVudCA9IGRvY3VtZW50LmF0dGFjaEV2ZW50XG52YXIgcmFmID0gcmVxdWlyZSgncmFmJylcblxudmFyIGNhbmNlbEZyYW1lID0gKGZ1bmN0aW9uKCl7XG4gIHZhciBjYW5jZWwgPSB3aW5kb3cuY2FuY2VsQW5pbWF0aW9uRnJhbWUgfHwgd2luZG93Lm1vekNhbmNlbEFuaW1hdGlvbkZyYW1lIHx8IHdpbmRvdy53ZWJraXRDYW5jZWxBbmltYXRpb25GcmFtZSB8fFxuICAgICAgICAgIHdpbmRvdy5jbGVhclRpbWVvdXRcbiAgcmV0dXJuIGZ1bmN0aW9uKGlkKXsgcmV0dXJuIGNhb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qLm9ubG9hZCA9IG9iamVjdExvYWRcbiAgICAgIG9iai50eXBlID0gJ3RleHQvaHRtbCdcbiAgICAgIG9iai5kYXRhID0gJ2Fib3V0OmJsYW5rJ1xuICAgICAgZWxlbWVudC5hcHBlbmRDaGlsZChvYmopXG4gICAgfVxuICB9XG4gIGVsZW1lbnQuX19yZXNpemVMaXN0ZW5lcnNfXy5wdXNoKGZuKVxuICByZXR1cm4gcmVtb3ZlTGlzdGVuZXIuYmluZChudWxsLCBlbGVtZW50LCBmbilcbn1cblxuXG5cbi8qKioqKioqKioqKioqKioqKlxuICoqIFdFQlBBQ0sgRk9PVEVSXG4gKiogLi9zcmMvaW5kZXguanNcbiAqKiBtb2R1bGUgaWQgPSAxXG4gKiogbW9kdWxlIGNodW5rcyA9IDBcbiAqKi8iXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Iiwic291cmNlUm9vdCI6IiJ9"); | ||
eval("var attachEvent = document.attachEvent\nvar once = __webpack_require__(2)\nvar raf = __webpack_require__(4)\n\nvar cancelFrame = (function(){\n var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame ||\n window.clearTimeout\n return function(id){ return cancel(id); }\n})()\n\nfunction resizeListener(e){\n var win = e.target || e.srcElement\n if (win.__resizeRAF__) cancelFrame(win.__resizeRAF__)\n win.__resizeRAF__ = raf(function(){\n var trigger = win.__resizeTrigger__\n trigger.__resizeListeners__.forEach(function(fn){\n fn.call(trigger, e)\n })\n })\n}\n\nfunction objectLoad(e){\n this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__\n this.contentDocument.defaultView.addEventListener('resize', resizeListener)\n}\n\nfunction removeListener (element, fn) {\n var trigger = element.__resizeTrigger__\n element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1)\n if (!element.__resizeListeners__.length) {\n if (attachEvent) element.detachEvent('onresize', resizeListener)\n else if (trigger.contentDocument) {\n trigger.contentDocument.defaultView.removeEventListener('resize', resizeListener)\n element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__)\n }\n }\n}\nmodule.exports = function(element, fn){\n if (!element.__resizeListeners__) {\n element.__resizeListeners__ = []\n if (attachEvent) {\n element.__resizeTrigger__ = element\n element.attachEvent('onresize', resizeListener)\n }\n else {\n if (getComputedStyle(element).position == 'static') element.style.position = 'relative'\n var obj = element.__resizeTrigger__ = document.createElement('object');\n obj.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;')\n obj.__resizeElement__ = element\n obj.onload = objectLoad\n obj.type = 'text/html'\n obj.data = 'about:blank'\n element.appendChild(obj)\n }\n }\n element.__resizeListeners__.push(fn)\n return once(removeListener.bind(null, element, fn))\n}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL3NyYy9pbmRleC5qcz85NTUyIl0sInNvdXJjZXNDb250ZW50IjpbInZhciBhdHRhY2hFdmVudCA9IGRvY3VtZW50LmF0dGFjaEV2ZW50XG52YXIgb25jZSA9IHJlcXVpcmUoJ29uY2UnKVxudmFyIHJhZiA9IHJlcXVpcmUoJ3JhZicp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E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0="); | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
eval("var wrappy = __webpack_require__(3)\nmodule.exports = wrappy(once)\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var f = function () {\n if (f.called) return f.value\n f.called = true\n return f.value = fn.apply(this, arguments)\n }\n f.called = false\n return f\n}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL34vb25jZS9vbmNlLmpzPzAwNDAiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHdyYXBweSA9IHJlcXVpcmUoJ3dyYXBweScpXG5tb2R1bGUuZXhwb3J0cyA9IHdyYXBweShvbmNlKVxuXG5vbmNlLnByb3RvID0gb25jZShmdW5jdGlvbiAoKSB7XG4gIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShGdW5jdGlvbi5wcm90b3R5cGUsICdvbmNlJywge1xuICAgIHZhbHVlOiBmdW5jdGlvbiAoKSB7XG4gICAgICByZXR1cm4gb25jZSh0aGlzKVxuICAgIH0sXG4gICAgY29uZmlndXJhYmxlOiB0cnVlXG4gIH0pXG59KVxuXG5mdW5jdGlvbiBvbmNlIChmbikge1xuICB2YXIgZiA9IGZ1bmN0aW9uICgpIHtcbiAgICBpZiAoZi5jYWxsZWQpIHJldHVybiBmLnZhbHVlXG4gICAgZi5jYWxsZWQgPSB0cnVlXG4gICAgcmV0dXJuIGYudmFsdWUgPSBmbi5hcHBseSh0aGlzLCBhcmd1bWVudHMpXG4gIH1cbiAgZi5jYWxsZWQgPSBmYWxzZVxuICByZXR1cm4gZlxufVxuXG5cblxuLyoqKioqKioqKioqKioqKioqXG4gKiogV0VCUEFDSyBGT09URVJcbiAqKiAuL34vb25jZS9vbmNlLmpzXG4gKiogbW9kdWxlIGlkID0gMlxuICoqIG1vZHVsZSBjaHVua3MgPSAwXG4gKiovIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Iiwic291cmNlUm9vdCI6IiJ9"); | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
eval("/**\n * Expose `requestAnimationFrame()`.\n */\n\nexports = module.exports = window.requestAnimationFrame\n || window.webkitRequestAnimationFrame\n || window.mozRequestAnimationFrame\n || fallback;\n\n/**\n * Fallback implementation.\n */\n\nvar prev = new Date().getTime();\nfunction fallback(fn) {\n var curr = new Date().getTime();\n var ms = Math.max(0, 16 - (curr - prev));\n var req = setTimeout(fn, ms);\n prev = curr;\n return req;\n}\n\n/**\n * Cancel.\n */\n\nvar cancel = window.cancelAnimationFrame\n || window.webkitCancelAnimationFrame\n || window.mozCancelAnimationFrame\n || window.clearTimeout;\n\nexports.cancel = function(id){\n cancel.call(window, id);\n};\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMi5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL34vY29tcG9uZW50LXJhZi9pbmRleC5qcz9hZmRhIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXhwb3NlIGByZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKWAuXG4gKi9cblxuZXhwb3J0cyA9IG1vZHV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TtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOyIsInNvdXJjZVJvb3QiOiIifQ=="); | ||
eval("// Returns a wrapper function that returns a wrapped callback\n// The wrapper function should do some stuff, and return a\n// presumably different callback function.\n// This makes sure that own properties are retained, so that\n// decorations and such are not lost along the way.\nmodule.exports = wrappy\nfunction wrappy (fn, cb) {\n if (fn && cb) return wrappy(fn)(cb)\n\n if (typeof fn !== 'function')\n throw new TypeError('need wrapper function')\n\n Object.keys(fn).forEach(function (k) {\n wrapper[k] = fn[k]\n })\n\n return wrapper\n\n function wrapper() {\n var args = new Array(arguments.length)\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n var ret = fn.apply(this, args)\n var cb = args[args.length-1]\n if (typeof ret === 'function' && ret !== cb) {\n Object.keys(cb).forEach(function (k) {\n ret[k] = cb[k]\n })\n }\n return ret\n }\n}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL34vd3JhcHB5L3dyYXBweS5qcz8xNTZmIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIFJldHVybnMgYSB3cmFwcGVyIGZ1bmN0aW9uIHRoYXQgcmV0dXJucyBhIHdyYXBwZWQgY2FsbGJhY2tcbi8vIFRoZSB3cmFwcGVyIGZ1bmN0aW9uIHNob3VsZCBkbyBzb21lIHN0dWZmLCBhbmQgcmV0dXJuIGFcbi8vIHByZXN1bWFibHkgZGlmZmVyZW50IGNhbGxiYWNrIGZ1bmN0aW9uLlxuLy8gVGhpcyBtYWtlcyBzdXJlIHRoYXQgb3duIHByb3BlcnRpZXMgYXJlIHJldGFp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ID0gMFxuICoqLyJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOyIsInNvdXJjZVJvb3QiOiIifQ=="); | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
eval("/**\n * Expose `requestAnimationFrame()`.\n */\n\nexports = module.exports = window.requestAnimationFrame\n || window.webkitRequestAnimationFrame\n || window.mozRequestAnimationFrame\n || fallback;\n\n/**\n * Fallback implementation.\n */\n\nvar prev = new Date().getTime();\nfunction fallback(fn) {\n var curr = new Date().getTime();\n var ms = Math.max(0, 16 - (curr - prev));\n var req = setTimeout(fn, ms);\n prev = curr;\n return req;\n}\n\n/**\n * Cancel.\n */\n\nvar cancel = window.cancelAnimationFrame\n || window.webkitCancelAnimationFrame\n || window.mozCancelAnimationFrame\n || window.clearTimeout;\n\nexports.cancel = function(id){\n cancel.call(window, id);\n};\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL34vY29tcG9uZW50LXJhZi9pbmRleC5qcz9hZmRhIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXhwb3NlIGByZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKWAuXG4gKi9cblxuZXhwb3J0cyA9IG1vZHVsZS5leHBvcnRzID0gd2luZG93LnJlcXVlc3RBbmltYXRpb25GcmFtZVxuICB8fCB3aW5kb3cud2Via2l0UmVxdWVzdEFuaW1hdGlvbkZyYW1lXG4gIHx8IHdpbmRvdy5tb3pSZXF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tBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOyIsInNvdXJjZVJvb3QiOiIifQ=="); | ||
/***/ } | ||
/******/ ]); |
@@ -6,6 +6,6 @@ // test entry file | ||
var preLoaders = webpack.module.preLoaders || [] | ||
// only files in lib | ||
// only files in src | ||
preLoaders.push({ | ||
include: [path.resolve('lib')], | ||
loader:'istanbul-instrumenter' | ||
include: [path.resolve('src')], | ||
loader: 'istanbul-instrumenter' | ||
}) | ||
@@ -12,0 +12,0 @@ webpack.module.preLoaders = preLoaders |
{ | ||
"name": "resizelistener", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -16,3 +16,5 @@ "main": "src/index.js", | ||
}, | ||
"keywords": ["resize"], | ||
"keywords": [ | ||
"resize" | ||
], | ||
"author": "chemzqm@gmail.com", | ||
@@ -49,3 +51,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"component-raf": "^1.2.0" | ||
"component-raf": "^1.2.0", | ||
"once": "^1.3.3" | ||
}, | ||
@@ -52,0 +55,0 @@ "browser": { |
# Onresize | ||
[![NPM version](https://img.shields.io/npm/v/resizelistener.svg?style=flat-square)](https://www.npmjs.com/package/resizelistener) | ||
[![Dependency Status](https://img.shields.io/david/chemzqm/onresize.svg?style=flat-square)](https://david-dm.org/chemzqm/onresize) | ||
[![Build Status](https://img.shields.io/travis/chemzqm/onresize/master.svg?style=flat-square)](http://travis-ci.org/chemzqm/onresize) | ||
@@ -3,0 +6,0 @@ Attach resize event listener(s) to element without polling. |
var attachEvent = document.attachEvent | ||
var once = require('once') | ||
var raf = require('raf') | ||
@@ -27,7 +28,8 @@ | ||
function removeListener (element, fn) { | ||
var trigger = element.__resizeTrigger__ | ||
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1) | ||
if (!element.__resizeListeners__.length) { | ||
if (attachEvent) element.detachEvent('onresize', resizeListener) | ||
else { | ||
element.__resizeTrigger__.contentDocument.defaultView.removeEventListener('resize', resizeListener) | ||
else if (trigger.contentDocument) { | ||
trigger.contentDocument.defaultView.removeEventListener('resize', resizeListener) | ||
element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__) | ||
@@ -56,3 +58,3 @@ } | ||
element.__resizeListeners__.push(fn) | ||
return removeListener.bind(null, element, fn) | ||
return once(removeListener.bind(null, element, fn)) | ||
} |
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
85241
25
821
46
2
+ Addedonce@^1.3.3
+ Addedonce@1.4.0(transitive)
+ Addedwrappy@1.0.2(transitive)