From d0541b7875ddd2083cd363c6931b2282903834a7 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 20 Dec 2018 18:48:49 -0800 Subject: [PATCH] Avoid case where random skin selection would cause webamp to jump when rendred --- src/FocusedSkin.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/FocusedSkin.js b/src/FocusedSkin.js index 2e031aa8..8797697f 100644 --- a/src/FocusedSkin.js +++ b/src/FocusedSkin.js @@ -39,21 +39,6 @@ class FocusedSkin extends React.Component { } this._webampLoadedEvents = new Subject(); this._transitionBeginEvents = new Subject(); - } - - componentDidMount() { - if (!this.props.centered) { - this._disposable.add( - timer(0).subscribe(() => { - // TODO: Observe DOM and recenter - this.setState(this._getCenteredState()); - this._transitionBeginEvents.next(null); - }) - ); - } else { - this._transitionBeginEvents.next(null); - } - const transitionComplete = this._transitionBeginEvents.pipe(delay(500)); // Emit after both Webamp has loaded, and the transition is complete @@ -78,6 +63,20 @@ class FocusedSkin extends React.Component { ); } + componentDidMount() { + if (!this.state.centered) { + this._disposable.add( + timer(0).subscribe(() => { + // TODO: Observe DOM and recenter + this.setState(this._getCenteredState()); + this._transitionBeginEvents.next(null); + }) + ); + } else { + this._transitionBeginEvents.next(null); + } + } + componentWillUnmount() { this._disposable.dispose(); }