react-resize-detector
Advanced tools
Comparing version 6.0.1-rc.1 to 6.0.1-rc.2
@@ -82,2 +82,5 @@ import React,{cloneElement,isValidElement,createRef,PureComponent,forwardRef,Component,useRef,useEffect,useState}from'react';import {findDOMNode}from'react-dom';import rafSchd from'raf-schd';import debounce from'lodash.debounce';import throttle from'lodash.throttle';/*! ***************************************************************************** | ||
var targetRef = _this.props.targetRef; | ||
if (isSSR()) { | ||
return; | ||
} | ||
if (targetRef && targetRef.current) { | ||
@@ -188,4 +191,7 @@ _this.targetRef.current = targetRef.current; | ||
_this.observableElement = null; | ||
if (isSSR()) { | ||
return _this; | ||
} | ||
_this.resizeHandler = patchResizeHandler(_this.createResizeHandler, refreshMode, refreshRate, refreshOptions); | ||
_this.resizeObserver = new ResizeObserver(_this.resizeHandler); | ||
_this.resizeObserver = new window.ResizeObserver(_this.resizeHandler); | ||
return _this; | ||
@@ -200,2 +206,5 @@ } | ||
ResizeDetector.prototype.componentWillUnmount = function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
this.resizeObserver.disconnect(); | ||
@@ -283,2 +292,5 @@ this.rafClean(); | ||
useEffect(function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
var notifyResizeAsync = createAsyncNotifier(onResizeCallback.current, setSize); | ||
@@ -298,3 +310,3 @@ var resizeCallback = function (entries) { | ||
resizeHandler.current = patchResizeHandler(resizeCallback, refreshMode, refreshRate, refreshOptions); | ||
var resizeObserver = new ResizeObserver(resizeHandler.current); | ||
var resizeObserver = new window.ResizeObserver(resizeHandler.current); | ||
if (ref.current) { | ||
@@ -301,0 +313,0 @@ resizeObserver.observe(ref.current); |
@@ -82,2 +82,5 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var React=require('react'),reactDom=require('react-dom'),rafSchd=require('raf-schd'),debounce=require('lodash.debounce'),throttle=require('lodash.throttle');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var React__default=/*#__PURE__*/_interopDefaultLegacy(React);var rafSchd__default=/*#__PURE__*/_interopDefaultLegacy(rafSchd);var debounce__default=/*#__PURE__*/_interopDefaultLegacy(debounce);var throttle__default=/*#__PURE__*/_interopDefaultLegacy(throttle);/*! ***************************************************************************** | ||
var targetRef = _this.props.targetRef; | ||
if (isSSR()) { | ||
return; | ||
} | ||
if (targetRef && targetRef.current) { | ||
@@ -188,4 +191,7 @@ _this.targetRef.current = targetRef.current; | ||
_this.observableElement = null; | ||
if (isSSR()) { | ||
return _this; | ||
} | ||
_this.resizeHandler = patchResizeHandler(_this.createResizeHandler, refreshMode, refreshRate, refreshOptions); | ||
_this.resizeObserver = new ResizeObserver(_this.resizeHandler); | ||
_this.resizeObserver = new window.ResizeObserver(_this.resizeHandler); | ||
return _this; | ||
@@ -200,2 +206,5 @@ } | ||
ResizeDetector.prototype.componentWillUnmount = function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
this.resizeObserver.disconnect(); | ||
@@ -283,2 +292,5 @@ this.rafClean(); | ||
React.useEffect(function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
var notifyResizeAsync = createAsyncNotifier(onResizeCallback.current, setSize); | ||
@@ -298,3 +310,3 @@ var resizeCallback = function (entries) { | ||
resizeHandler.current = patchResizeHandler(resizeCallback, refreshMode, refreshRate, refreshOptions); | ||
var resizeObserver = new ResizeObserver(resizeHandler.current); | ||
var resizeObserver = new window.ResizeObserver(resizeHandler.current); | ||
if (ref.current) { | ||
@@ -301,0 +313,0 @@ resizeObserver.observe(ref.current); |
@@ -1,2 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var ResizeObserver=require('resize-observer-polyfill'),React=require('react'),reactDom=require('react-dom'),rafSchd=require('raf-schd'),debounce=require('lodash.debounce'),throttle=require('lodash.throttle');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var ResizeObserver__default=/*#__PURE__*/_interopDefaultLegacy(ResizeObserver);var React__default=/*#__PURE__*/_interopDefaultLegacy(React);var rafSchd__default=/*#__PURE__*/_interopDefaultLegacy(rafSchd);var debounce__default=/*#__PURE__*/_interopDefaultLegacy(debounce);var throttle__default=/*#__PURE__*/_interopDefaultLegacy(throttle);/*! ***************************************************************************** | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var React=require('react'),reactDom=require('react-dom'),rafSchd=require('raf-schd'),debounce=require('lodash.debounce'),throttle=require('lodash.throttle');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var React__default=/*#__PURE__*/_interopDefaultLegacy(React);var rafSchd__default=/*#__PURE__*/_interopDefaultLegacy(rafSchd);var debounce__default=/*#__PURE__*/_interopDefaultLegacy(debounce);var throttle__default=/*#__PURE__*/_interopDefaultLegacy(throttle);/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -82,2 +82,5 @@ | ||
var targetRef = _this.props.targetRef; | ||
if (isSSR()) { | ||
return; | ||
} | ||
if (targetRef && targetRef.current) { | ||
@@ -188,4 +191,7 @@ _this.targetRef.current = targetRef.current; | ||
_this.observableElement = null; | ||
if (isSSR()) { | ||
return _this; | ||
} | ||
_this.resizeHandler = patchResizeHandler(_this.createResizeHandler, refreshMode, refreshRate, refreshOptions); | ||
_this.resizeObserver = new ResizeObserver__default['default'](_this.resizeHandler); | ||
_this.resizeObserver = new window.ResizeObserver(_this.resizeHandler); | ||
return _this; | ||
@@ -200,2 +206,5 @@ } | ||
ResizeDetector.prototype.componentWillUnmount = function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
this.resizeObserver.disconnect(); | ||
@@ -235,3 +244,5 @@ this.rafClean(); | ||
return ResizeDetector; | ||
}(React.PureComponent));function withResizeDetector(ComponentInner, options) { | ||
}(React.PureComponent)); | ||
//# sourceMappingURL=ResizeDetector.js.map | ||
function withResizeDetector(ComponentInner, options) { | ||
var ResizeDetectorHOC = /** @class */ (function (_super) { | ||
@@ -284,2 +295,5 @@ __extends(ResizeDetectorHOC, _super); | ||
React.useEffect(function () { | ||
if (isSSR()) { | ||
return; | ||
} | ||
var notifyResizeAsync = createAsyncNotifier(onResizeCallback.current, setSize); | ||
@@ -299,3 +313,3 @@ var resizeCallback = function (entries) { | ||
resizeHandler.current = patchResizeHandler(resizeCallback, refreshMode, refreshRate, refreshOptions); | ||
var resizeObserver = new ResizeObserver__default['default'](resizeHandler.current); | ||
var resizeObserver = new window.ResizeObserver(resizeHandler.current); | ||
if (ref.current) { | ||
@@ -314,2 +328,4 @@ resizeObserver.observe(ref.current); | ||
return __assign({ ref: ref }, size); | ||
}exports.default=ResizeDetector;exports.useResizeDetector=useResizeDetector;exports.withResizeDetector=withResizeDetector;//# sourceMappingURL=withPolyfill.js.map | ||
} | ||
//# sourceMappingURL=useResizeDetector.js.map | ||
exports.default=ResizeDetector;exports.useResizeDetector=useResizeDetector;exports.withResizeDetector=withResizeDetector;//# sourceMappingURL=withPolyfill.js.map |
@@ -56,3 +56,3 @@ { | ||
"author": "Vitalii Maslianok <maslianok@gmail.com> (https://github.com/maslianok)", | ||
"version": "6.0.1-rc.1", | ||
"version": "6.0.1-rc.2", | ||
"bugs": { | ||
@@ -59,0 +59,0 @@ "url": "https://github.com/maslianok/react-resize-detector/issues" |
# Handle element resizes like it's 2021! | ||
<img src="https://img.shields.io/npm/dy/react-resize-detector?style=flat-square"> <img src="https://img.shields.io/npm/dm/react-resize-detector?style=flat-square"> <img src="https://badgen.net/bundlephobia/minzip/react-resize-detector?style=flat-square"> <img src="https://badgen.net/bundlephobia/tree-shaking/react-resize-detector?style=flat-square"> | ||
<img src="https://img.shields.io/npm/dm/react-resize-detector?style=flat-square"> <img src="https://badgen.net/bundlephobia/minzip/react-resize-detector?style=flat-square"> <img src="https://badgen.net/bundlephobia/tree-shaking/react-resize-detector?style=flat-square"> | ||
@@ -9,3 +9,3 @@ #### [Live demo](http://maslianok.github.io/react-resize-detector/) | ||
🐥 Tiny [~3kb](https://bundlephobia.com/result?p=react-resize-detector) | ||
🐥 Tiny <a href="https://bundlephobia.com/result?p=react-resize-detector" target="__blank">~3kb</a> | ||
@@ -16,4 +16,6 @@ 🐼 Written in TypeScript | ||
🐠 Trusted by [many different projects](https://www.npmjs.com/browse/depended/react-resize-detector) | ||
🐠 Used by <a href="https://github.com/maslianok/react-resize-detector/network/dependents" target="__blank">20k+ repositories</a> | ||
🦄 Generating 35M+ downloads/year | ||
No `window.resize` listeners! No timeouts! No 👑 viruses! :) | ||
@@ -20,0 +22,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
172784
1094
225