react-resize-detector
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -88,3 +88,3 @@ 'use strict'; | ||
_this.createResizeObserver = function (entries) { | ||
_this.createResizeHandler = function (entries) { | ||
var _this$props = _this.props, | ||
@@ -102,5 +102,7 @@ handleWidth = _this$props.handleWidth, | ||
var notifyHeight = handleHeight && _this.state.height !== height; | ||
if (!_this.skipOnMount && (notifyWidth || notifyHeight)) { | ||
onResize(width, height); | ||
_this.setState({ width: width, height: height }); | ||
if (!_this.skipOnMount && (notifyWidth || notifyHeight) && typeof window !== 'undefined') { | ||
_this.animationFrameID = window.requestAnimationFrame(function () { | ||
onResize(width, height); | ||
_this.setState({ width: width, height: height }); | ||
}); | ||
} | ||
@@ -144,4 +146,2 @@ _this.skipOnMount = false; | ||
_this.skipOnMount = skipOnMount; | ||
_this.state = { | ||
@@ -152,5 +152,8 @@ width: undefined, | ||
var resizeObserver = listMode[refreshMode] && listMode[refreshMode](_this.createResizeObserver, refreshRate) || _this.createResizeObserver; | ||
_this.skipOnMount = skipOnMount; | ||
_this.animationFrameID = null; | ||
_this.ro = new _resizeObserverPolyfill2.default(resizeObserver); | ||
_this.resizeHandler = listMode[refreshMode] && listMode[refreshMode](_this.createResizeHandler, refreshRate) || _this.createResizeHandler; | ||
_this.ro = new _resizeObserverPolyfill2.default(_this.resizeHandler); | ||
return _this; | ||
@@ -170,2 +173,9 @@ } | ||
if (resizableElement) this.ro.unobserve(resizableElement); | ||
if (typeof window !== 'undefined' && this.animationFrameID) { | ||
window.cancelAnimationFrame(this.animationFrameID); | ||
} | ||
if (this.resizeHandler && this.resizeHandler.cancel) { | ||
// cancel debounced handler | ||
this.resizeHandler.cancel(); | ||
} | ||
} | ||
@@ -172,0 +182,0 @@ }, { |
{ | ||
"author": "Vitalii Maslianok <maslianok@gmail.com> (https://github.com/maslianok)", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"bugs": { | ||
@@ -5,0 +5,0 @@ "url": "https://github.com/maslianok/react-resize-detector/issues" |
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
120602
194