From 3a655606912dd6dd95cdd18ff08ffb11a001f184 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 19 Jun 2017 14:59:10 +0200 Subject: [PATCH] Allow updating height and color options through props Use Wavesurfer setter methods to update `waveColor`, `progressColor` and `height` if the value changed inside the `options` prop. --- src/react-wavesurfer.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/react-wavesurfer.js b/src/react-wavesurfer.js index 6b77321..c1c240b 100644 --- a/src/react-wavesurfer.js +++ b/src/react-wavesurfer.js @@ -238,6 +238,22 @@ class Wavesurfer extends Component { this._wavesurfer.setPlaybackRate(nextProps.options.audioRate); } + if (nextProps.options.waveColor !== this.props.options.waveColor) { + this._wavesurfer.setWaveColor(nextProps.options.waveColor); + } + + if (nextProps.options.progressColor !== this.props.options.progressColor) { + this._wavesurfer.setProgressColor(nextProps.options.progressColor); + } + + if (nextProps.options.cursorColor !== this.props.options.cursorColor) { + this._wavesurfer.setCursorColor(nextProps.options.cursorColor); + } + + if (nextProps.options.height !== this.props.options.height) { + this._wavesurfer.setHeight(nextProps.options.height); + } + // turn responsive on if (nextProps.responsive && this.props.responsive !== nextProps.responsive) { window.addEventListener('resize', this._handleResize, false);