diff --git a/dist/vis.js b/dist/vis.js index e62858a1..df5bb392 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 4.14.0 - * @date 2016-02-23 + * @date 2016-03-01 * * @license * Copyright (C) 2011-2016 Almende B.V, http://almende.com @@ -37331,6 +37331,7 @@ return /******/ (function(modules) { // webpackBootstrap this.resizeTimer = undefined; this.resizeFunction = this._onResize.bind(this); this.cameraState = {}; + this.initialized = false; this.options = {}; this.defaultOptions = { @@ -37413,10 +37414,15 @@ return /******/ (function(modules) { // webpackBootstrap value: function _getCameraState() { var pixelRatio = arguments.length <= 0 || arguments[0] === undefined ? this.pixelRatio : arguments[0]; - this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; - this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; - this.cameraState.scale = this.body.view.scale; - this.cameraState.position = this.DOMtoCanvas({ x: 0.5 * this.frame.canvas.width / pixelRatio, y: 0.5 * this.frame.canvas.height / pixelRatio }); + if (this.initialized === true) { + this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; + this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; + this.cameraState.scale = this.body.view.scale; + this.cameraState.position = this.DOMtoCanvas({ + x: 0.5 * this.frame.canvas.width / pixelRatio, + y: 0.5 * this.frame.canvas.height / pixelRatio + }); + } } /** @@ -37655,6 +37661,8 @@ return /******/ (function(modules) { // webpackBootstrap this._setCameraState(); } + // set initialized so the get and set camera will work from now on. + this.initialized = true; return emitEvent; } }, { diff --git a/lib/network/modules/Canvas.js b/lib/network/modules/Canvas.js index 9abe1f5d..726d1f63 100644 --- a/lib/network/modules/Canvas.js +++ b/lib/network/modules/Canvas.js @@ -17,6 +17,7 @@ class Canvas { this.resizeTimer = undefined; this.resizeFunction = this._onResize.bind(this); this.cameraState = {}; + this.initialized = false; this.options = {}; this.defaultOptions = { @@ -88,10 +89,15 @@ class Canvas { * @private */ _getCameraState(pixelRatio = this.pixelRatio) { - this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; - this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; - this.cameraState.scale = this.body.view.scale; - this.cameraState.position = this.DOMtoCanvas({x: 0.5 * this.frame.canvas.width / pixelRatio, y: 0.5 * this.frame.canvas.height / pixelRatio}); + if (this.initialized === true) { + this.cameraState.previousWidth = this.frame.canvas.width / pixelRatio; + this.cameraState.previousHeight = this.frame.canvas.height / pixelRatio; + this.cameraState.scale = this.body.view.scale; + this.cameraState.position = this.DOMtoCanvas({ + x: 0.5 * this.frame.canvas.width / pixelRatio, + y: 0.5 * this.frame.canvas.height / pixelRatio + }); + } } /** @@ -311,6 +317,9 @@ class Canvas { this._setCameraState(); } + + // set initialized so the get and set camera will work from now on. + this.initialized = true; return emitEvent; }; diff --git a/test/networkTest.html b/test/networkTest.html index 71208a78..b10873b4 100644 --- a/test/networkTest.html +++ b/test/networkTest.html @@ -20,164 +20,41 @@