Skip to content

Commit

Permalink
allow disabling automatic stage instantiation (#92)
Browse files Browse the repository at this point in the history
* allow disabling automatic stage instantiation

* update CI node version
  • Loading branch information
ericente authored Jun 12, 2019
1 parent 2bb9ae1 commit 4a2450f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "6"
- "8"

install:
- npm install xvfb-maybe
Expand Down
6 changes: 4 additions & 2 deletions ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ declare namespace PIXI.animate {

interface LoadOptions {
stage:any;
parent:PIXI.Container;
basePath:string;
parent?:PIXI.Container;
basePath?:string;
complete?:LoadCallback;
createInstance?:boolean;
}

type LoadCallback = (instance:MovieClip) => void;
Expand Down
6 changes: 4 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ declare namespace PIXI.animate {

interface LoadOptions {
stage:any;
parent:PIXI.Container;
basePath:string;
parent?:PIXI.Container;
basePath?:string;
complete?:LoadCallback;
createInstance?:boolean;
}

type LoadCallback = (instance:MovieClip) => void;
Expand Down
6 changes: 4 additions & 2 deletions src/animate/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @param {Object} [options.stage.assets] Assets used to preload
* @param {PIXI.Container} options.parent The Container to auto-add the stage to.
* @param {String} [options.basePath] Base root directory
* @param {boolean} [options.createInstance] enable or disable automatic instantiation of stage
* @return {PIXI.loaders.Loader} instance of PIXI resource loader
*/
/**
Expand Down Expand Up @@ -109,13 +110,14 @@ const load = function(options, parent, complete, basePath, loader, metadata) {
stage: null,
parent: null,
basePath: '',
complete: null
complete: null,
createInstance: true
}, options || {});

loader = loader || new PIXI.loaders.Loader();

function done() {
let instance = typeof options.stage === "function" ? new options.stage() : null;
let instance = (options.createInstance && typeof options.stage === "function") ? new options.stage() : null;
if (options.parent) {
options.parent.addChild(instance);
}
Expand Down

0 comments on commit 4a2450f

Please sign in to comment.