From 84f2a7d197d7d7215d6a7377520fa0dad9481124 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 28 Jun 2017 20:18:40 +0800 Subject: [PATCH] bug --- bi/core.js | 15 +++++++++------ docs/core.js | 15 +++++++++------ src/core/utils/detectElementResize.js | 15 +++++++++------ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/bi/core.js b/bi/core.js index 80620d72c..fc889cc55 100644 --- a/bi/core.js +++ b/bi/core.js @@ -8104,10 +8104,10 @@ BI.ScalingCellSizeAndPositionManager.prototype = { _window = this } - var attachEvent = typeof document !== 'undefined' && document.attachEvent; + var addEventListener = typeof document !== 'undefined' && document.addEventListener; var stylesCreated = false; - if (!attachEvent) { + if (addEventListener) { var requestFrame = (function () { var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) { @@ -8214,8 +8214,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = { } var addResizeListener = function (element, fn) { - if (attachEvent) element.attachEvent('onresize', fn); - else { + if (addEventListener){ if (!element.__resizeTriggers__) { if (getComputedStyle(element).position === 'static') element.style.position = 'relative'; createStyles(); @@ -8235,17 +8234,21 @@ BI.ScalingCellSizeAndPositionManager.prototype = { }); } element.__resizeListeners__.push(fn); + + } else { + element.attachEvent('onresize', fn); } }; var removeResizeListener = function (element, fn) { - if (attachEvent) element.detachEvent('onresize', fn); - else { + if (addEventListener) { element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); if (!element.__resizeListeners__.length) { element.removeEventListener('scroll', scrollListener, true); element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); } + } else { + element.detachEvent('onresize', fn); } }; diff --git a/docs/core.js b/docs/core.js index c27a5c615..4ac7a6f8d 100644 --- a/docs/core.js +++ b/docs/core.js @@ -16841,10 +16841,10 @@ BI.ScalingCellSizeAndPositionManager.prototype = { _window = this } - var attachEvent = typeof document !== 'undefined' && document.attachEvent; + var addEventListener = typeof document !== 'undefined' && document.addEventListener; var stylesCreated = false; - if (!attachEvent) { + if (addEventListener) { var requestFrame = (function () { var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) { @@ -16951,8 +16951,7 @@ BI.ScalingCellSizeAndPositionManager.prototype = { } var addResizeListener = function (element, fn) { - if (attachEvent) element.attachEvent('onresize', fn); - else { + if (addEventListener){ if (!element.__resizeTriggers__) { if (getComputedStyle(element).position === 'static') element.style.position = 'relative'; createStyles(); @@ -16972,17 +16971,21 @@ BI.ScalingCellSizeAndPositionManager.prototype = { }); } element.__resizeListeners__.push(fn); + + } else { + element.attachEvent('onresize', fn); } }; var removeResizeListener = function (element, fn) { - if (attachEvent) element.detachEvent('onresize', fn); - else { + if (addEventListener) { element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); if (!element.__resizeListeners__.length) { element.removeEventListener('scroll', scrollListener, true); element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); } + } else { + element.detachEvent('onresize', fn); } }; diff --git a/src/core/utils/detectElementResize.js b/src/core/utils/detectElementResize.js index 18a5a39d6..6686ed1b0 100644 --- a/src/core/utils/detectElementResize.js +++ b/src/core/utils/detectElementResize.js @@ -18,10 +18,10 @@ _window = this } - var attachEvent = typeof document !== 'undefined' && document.attachEvent; + var addEventListener = typeof document !== 'undefined' && document.addEventListener; var stylesCreated = false; - if (!attachEvent) { + if (addEventListener) { var requestFrame = (function () { var raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function (fn) { @@ -128,8 +128,7 @@ } var addResizeListener = function (element, fn) { - if (attachEvent) element.attachEvent('onresize', fn); - else { + if (addEventListener){ if (!element.__resizeTriggers__) { if (getComputedStyle(element).position === 'static') element.style.position = 'relative'; createStyles(); @@ -149,17 +148,21 @@ }); } element.__resizeListeners__.push(fn); + + } else { + element.attachEvent('onresize', fn); } }; var removeResizeListener = function (element, fn) { - if (attachEvent) element.detachEvent('onresize', fn); - else { + if (addEventListener) { element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); if (!element.__resizeListeners__.length) { element.removeEventListener('scroll', scrollListener, true); element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); } + } else { + element.detachEvent('onresize', fn); } };