From eba82f098a578667e90fb22e1a3a2167d3cf303d Mon Sep 17 00:00:00 2001 From: Adrien Date: Mon, 15 May 2017 15:31:39 +0200 Subject: [PATCH] Add the onConfigCompleteLoad event to the Viewer. (#72) --- src/core/Viewer.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/core/Viewer.js b/src/core/Viewer.js index 469c14e0..b2d5e8ef 100755 --- a/src/core/Viewer.js +++ b/src/core/Viewer.js @@ -294,6 +294,14 @@ FORGE.Viewer = function(parent, config, callbacks) */ this._onResume = null; + /** + * Event dispatcher for the on config load complete event. + * @name FORGE.Viewer#_onConfigLoadComplete + * @type {FORGE.EventDispatcher} + * @private + */ + this._onConfigLoadComplete = null; + /** * Callback function for the viewer. * @name FORGE.Viewer#_callbacks @@ -497,6 +505,11 @@ FORGE.Viewer.prototype._parseMainConfig = function(config) } this._raf.start(); + + if (this._onConfigLoadComplete !== null) + { + this._onConfigLoadComplete.dispatch(); + } }; /** @@ -801,6 +814,12 @@ FORGE.Viewer.prototype.destroy = function() this._onResume = null; } + if (this._onConfigLoadComplete !== null) + { + this._onConfigLoadComplete.destroy(); + this._onConfigLoadComplete = null; + } + FORGE.VIEWERS.splice(this._uid, 1); FORGE.BaseObject.prototype.destroy.call(this); @@ -1411,3 +1430,23 @@ Object.defineProperty(FORGE.Viewer.prototype, "onResume", return this._onResume; } }); + +/** + * Get the "onConfigLoadComplete" {@link FORGE.EventDispatcher} of the viewer. + * @name FORGE.Viewer#onConfigLoadComplete + * @readonly + * @type {FORGE.EventDispatcher} + */ +Object.defineProperty(FORGE.Viewer.prototype, "onConfigLoadComplete", +{ + /** @this {FORGE.Viewer} */ + get: function() + { + if (this._onConfigLoadComplete === null) + { + this._onConfigLoadComplete = new FORGE.EventDispatcher(this); + } + + return this._onConfigLoadComplete; + } +});