Skip to content
This repository has been archived by the owner on Aug 7, 2018. It is now read-only.

Commit

Permalink
Allow updating height and color options through props
Browse files Browse the repository at this point in the history
Use Wavesurfer setter methods to update `waveColor`, `progressColor`
and `height` if the value changed inside the `options` prop.
  • Loading branch information
tf committed Jun 20, 2017
1 parent 99c04cc commit 1ff41c5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/react-wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ 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.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);
Expand Down

0 comments on commit 1ff41c5

Please sign in to comment.