Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
this.resizeObserver = new ResizeObserver(entries => {
this.setState({
progressWidth: entries[0].contentRect.width - progressMargin * 2
});
});
this.resizeObserver.observe(this.progressBox);
}
constructor(props) {
super(props);
this.width = undefined;
this.height = undefined;
this.skipOnMount = props.skipOnMount;
this.onResize = debounce((...args) => this.props.onResize(...args), debounceTime !== undefined ? debounceTime : props.debounceTime || 1000);
this.ro = new ResizeObserver((entries) => {
entries.forEach((entry) => {
const { width, height } = entry.contentRect;
const notifyWidth = this.props.handleWidth && this.width !== width;
const notifyHeight = this.props.handleHeight && this.height !== height;
if (!this.skipOnMount && (notifyWidth || notifyHeight)) {
this.onResize({width, height});
}
this.width = width;
this.height = height;
this.skipOnMount = false;
});
});
}
findDomNode = () => {
componentDidMount() {
const elem = document.getElementById(this.randomId);
this.resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
this.setState({
width: entry.contentRect.width
});
}
});
this.resizeObserver.observe(elem);
}
const observeSizeChanges = () => {
$bgEle = document.querySelectorAll(".background");
$container = document.querySelector("#app");
new ResizeObserver(changeBackgroundSize).observe($container);
};