From aa9628be9f77958b4e8e7286a0eb0968d49be426 Mon Sep 17 00:00:00 2001 From: MatanMaimon Date: Tue, 8 Oct 2019 14:57:00 +0300 Subject: [PATCH] support specific update/resize support manually dispatch event ("resize") with extra params ("detail": { "fitElements": [ELEMENT1, ELEMENT2] }) to resize and process only those specific Textfit elements (and not all Textfits) --- src/Textfit.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Textfit.js b/src/Textfit.js index 7e7089b..3b446b8 100644 --- a/src/Textfit.js +++ b/src/Textfit.js @@ -83,11 +83,21 @@ export default class TextFit extends React.Component { this.pid = uniqueId(); } - handleWindowResize = () => { - this.process(); + handleWindowResize = (fitIndexesArray = undefined) => { + this.process(fitIndexesArray); } - process() { + process(fitIndexesArray = undefined) { + + // if have specific Textfit to resize, and this one is not one of them.. + const fitElements = + fitIndexesArray && + fitIndexesArray.detail && + fitIndexesArray.detail.fitElements; + if (fitElements && !fitElements.includes(this._parent)) { + return; + } + const { min, max, mode, forceSingleModeWidth, onReady } = this.props; const el = this._parent; const wrapper = this._child;