From d690fb91e6bd59f70a22c9e478b2b04cd344e149 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 27 May 2022 10:35:40 -0700 Subject: [PATCH 1/2] comment out unused feature --- src/OnImagesLoaded.tsx | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/OnImagesLoaded.tsx b/src/OnImagesLoaded.tsx index b1ff925..2378f16 100644 --- a/src/OnImagesLoaded.tsx +++ b/src/OnImagesLoaded.tsx @@ -46,7 +46,7 @@ export default class OnImagesLoaded extends Component { private mounted: boolean private _imgs: any[] private imageLoad: HTMLDivElement | null - private observer: MutationObserver + // private observer: MutationObserver private invokedCount: number constructor(props: Props) { @@ -64,7 +64,7 @@ export default class OnImagesLoaded extends Component { this.mounted = false this._imgs = [] this.imageLoad = null - this.observer = new MutationObserver(noop) + // this.observer = new MutationObserver(noop) this.invokedCount = 0 } @@ -78,36 +78,36 @@ export default class OnImagesLoaded extends Component { componentWillUnmount() { this.mounted = false this._imgs.length > 0 ? this._removeImageListeners() : null - this.observer.disconnect() - } - - private initObserver() { - this.observer = new MutationObserver((mutationsList) => { - for (const mutation of mutationsList) { - if (mutation.type !== 'childList') return - const { imageCount } = this.state - const nextCount = imageCount + mutation.addedNodes.length - mutation.removedNodes.length - this.setState({ - imageCount: nextCount - }, () => { - mutation.removedNodes.forEach(node => { - if (node.nodeName === 'IMG') { - node.addEventListener('load', this._onUpdate) - } - }) - mutation.addedNodes.forEach(node => { - if (node.nodeName === 'IMG') { - node.addEventListener('load', this._onUpdate) - } - }) - }) - } - }) - if (this.imageLoad) { - const config = { attributes: true, childList: true, subtree: true }; - this.observer.observe(this.imageLoad, config) - } - } + // this.observer.disconnect() + } + + // private initObserver() { + // this.observer = new MutationObserver((mutationsList) => { + // for (const mutation of mutationsList) { + // if (mutation.type !== 'childList') return + // const { imageCount } = this.state + // const nextCount = imageCount + mutation.addedNodes.length - mutation.removedNodes.length + // this.setState({ + // imageCount: nextCount + // }, () => { + // mutation.removedNodes.forEach(node => { + // if (node.nodeName === 'IMG') { + // node.addEventListener('load', this._onUpdate) + // } + // }) + // mutation.addedNodes.forEach(node => { + // if (node.nodeName === 'IMG') { + // node.addEventListener('load', this._onUpdate) + // } + // }) + // }) + // } + // }) + // if (this.imageLoad) { + // const config = { attributes: true, childList: true, subtree: true }; + // this.observer.observe(this.imageLoad, config) + // } + // } private _onUpdate() { if (!this.mounted) return From 727d12cb7b68304dc55ce1df7745fc620e63142d Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 27 May 2022 10:38:18 -0700 Subject: [PATCH 2/2] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4247cde..2da79ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-on-images-loaded", - "version": "2.2.7", + "version": "2.2.8", "description": "OnImagesLoaded", "license": "MIT", "main": "lib/OnImagesLoaded.js",