Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.5.0] - unreleased

### Added

- Added a check to make sure plugin preloads are finished before opening up the application to avoid race conditions.

## [2.4.6] - unreleased

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion dist/SpringRoll-Container-umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SpringRoll-Container-umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Container extends PluginManager {
super({ plugins });

this.iframe = iframeOrSelector instanceof HTMLIFrameElement ? iframeOrSelector : document.querySelector(iframeOrSelector);
this.iframe.style.backgroundColor = 'black';

if (null === this.iframe) {
throw new Error('No iframe was found with the provided selector');
Expand Down Expand Up @@ -141,6 +142,15 @@ export class Container extends PluginManager {
* @memberof Container
*/
_internalOpen(userPath, { singlePlay = false, playOptions = null } = {}) {
// If plugin preloads are still going wait for them to finish before opening the Application
if (this.preloading) {
this.client.on('preloadsFinished', () => {
this._internalOpen(userPath, { singlePlay, playOptions });
});

return;
}

const options = { singlePlay, playOptions };
this.reset();

Expand Down
4 changes: 4 additions & 0 deletions src/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class PluginManager {
*/
constructor({ plugins = [] }) {
this.client = new Bellhop();
this.preloading = true;
// @ts-ignore
this.client.hidden = this.client.receive.bind(this.client);
// @ts-ignore
Expand Down Expand Up @@ -57,6 +58,9 @@ export default class PluginManager {
plugin => plugin.preloadFailed !== true
);

this.preloading = false;
this.client.trigger('preloadsFinished');

//init
this.plugins.forEach(plugin => {
if (!plugin.init) {
Expand Down