mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-23 18:17:38 +00:00
Don't animate the overlay on page load
This commit is contained in:
parent
0e75c60007
commit
7dde2a05ce
3 changed files with 15 additions and 6 deletions
|
|
@ -35,7 +35,7 @@ class App extends React.Component {
|
|||
}
|
||||
/>
|
||||
{!this._sizeIsSet() || this.props.selectedSkinHash == null || (
|
||||
<Overlay>
|
||||
<Overlay shouldAnimate={this.props.overlayShouldAnimate}>
|
||||
<FocusedSkin initialHeight={rowHeight} initialWidth={columnWidth} />
|
||||
</Overlay>
|
||||
)}
|
||||
|
|
@ -45,7 +45,8 @@ class App extends React.Component {
|
|||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
selectedSkinHash: Selectors.getSelectedSkinHash(state)
|
||||
selectedSkinHash: Selectors.getSelectedSkinHash(state),
|
||||
overlayShouldAnimate: Selectors.overlayShouldAnimate(state)
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(App);
|
||||
|
|
|
|||
|
|
@ -17,11 +17,15 @@ class Overlay extends React.Component {
|
|||
componentDidMount() {
|
||||
window.document.addEventListener("keydown", this._handleKeyDown);
|
||||
// TODO: This is technically a race condition, since we could unmount before this fires.
|
||||
requestAnimationFrame(() => {
|
||||
// This does not seem to work the first time.
|
||||
// This should _not_ work on page load
|
||||
if (this.props.shouldAnimate) {
|
||||
setTimeout(() => {
|
||||
// This does not seem to work the first time.
|
||||
// This should _not_ work on page load
|
||||
document.body.classList.add("overlay-open");
|
||||
}, 0);
|
||||
} else {
|
||||
document.body.classList.add("overlay-open");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ export function getSelectedSkinPosition(state) {
|
|||
return state.selectedSkinPosition;
|
||||
}
|
||||
|
||||
export function overlayShouldAnimate(state) {
|
||||
return getSelectedSkinPosition(state) != null;
|
||||
}
|
||||
|
||||
export function getSelectedSkinUrl(state) {
|
||||
const hash = getSelectedSkinHash(state);
|
||||
return hash == null ? null : Utils.screenshotUrlFromHash(hash);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue