diff --git a/js/about/newtab.js b/js/about/newtab.js index 3ce36aa432e..1b5236b4b83 100644 --- a/js/about/newtab.js +++ b/js/about/newtab.js @@ -32,6 +32,7 @@ class NewTabPage extends React.Component { this.state = { showSiteRemovalNotification: false, imageLoadFailed: false, + imageLoadCompleted: false, updatedStamp: undefined, showEmptyPage: true, showImages: false, @@ -61,6 +62,7 @@ class NewTabPage extends React.Component { }) }) } + get showImages () { return this.state.showImages && !!this.state.backgroundImage } @@ -227,6 +229,21 @@ class NewTabPage extends React.Component { : this.fallbackImage }) } + /** + * Displays background image once it loads + */ + onImageLoadCompleted () { + this.setState({ + imageLoadCompleted: true + }) + } + /** + * Helper for background className + */ + get backgroundClassName () { + return 'backgroundContainer' + + (this.state.imageLoadCompleted ? ' backgroundLoaded' : '') + } render () { // don't render if user prefers an empty page @@ -249,12 +266,17 @@ class NewTabPage extends React.Component { backgroundProps.style = this.state.backgroundImage.style gradientClassName = 'bgGradient' } - return