From 350e69b5fba4972c077e99e851f01df0aab0adf0 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Wed, 7 Jan 2015 17:39:04 +0100 Subject: [PATCH] - Community fix for SVG images in IE11, thanks @dponch! --- HISTORY.md | 1 + dist/vis.js | 12 ++++++++++-- lib/network/Images.js | 9 +++++++++ lib/network/Network.js | 3 +-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index cd0d87d1..838969ba 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -23,6 +23,7 @@ http://visjs.org - Improved physics handling for smoother network simulation. - Fixed infinite loop when an image can not be found and no brokenImage is provided. - Added getBoundingBox method. +- Community fix for SVG images in IE11, thanks @dponch! ### Graph2d diff --git a/dist/vis.js b/dist/vis.js index 26449283..35bc492d 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -24650,6 +24650,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { supportMovingStatus = this._doInSupportSector("_discreteStepNodes"); } + // gather movement data from all sectors, if one moves, we are NOT stabilzied for (var i = 0; i < mainMoving.length; i++) {mainMovingStatus = mainMoving[0] || mainMovingStatus;} @@ -24709,8 +24710,6 @@ return /******/ (function(modules) { // webpackBootstrap } if (!this.timer) { - - if (this.requiresTimeout == true) { this.timer = window.setTimeout(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function } @@ -27543,6 +27542,15 @@ return /******/ (function(modules) { // webpackBootstrap var me = this; var img = new Image(); img.onload = function () { + + // IE11 fix -- thanks dponch! + if (this.width == 0) { + document.body.appendChild(this); + this.width = this.offsetWidth; + this.height = this.offsetHeight; + document.body.removeChild(this); + } + if (me.callback) { me.images[url] = img; me.callback(this); diff --git a/lib/network/Images.js b/lib/network/Images.js index 0a4ff046..0097fb16 100644 --- a/lib/network/Images.js +++ b/lib/network/Images.js @@ -28,6 +28,15 @@ Images.prototype.load = function(url, brokenUrl) { var me = this; var img = new Image(); img.onload = function () { + + // IE11 fix -- thanks dponch! + if (this.width == 0) { + document.body.appendChild(this); + this.width = this.offsetWidth; + this.height = this.offsetHeight; + document.body.removeChild(this); + } + if (me.callback) { me.images[url] = img; me.callback(this); diff --git a/lib/network/Network.js b/lib/network/Network.js index 7b3fccaf..ad4f0908 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -2165,6 +2165,7 @@ Network.prototype._physicsTick = function() { if (this.constants.smoothCurves.enabled == true && this.constants.smoothCurves.dynamic == true) { supportMovingStatus = this._doInSupportSector("_discreteStepNodes"); } + // gather movement data from all sectors, if one moves, we are NOT stabilzied for (var i = 0; i < mainMoving.length; i++) {mainMovingStatus = mainMoving[0] || mainMovingStatus;} @@ -2224,8 +2225,6 @@ Network.prototype.start = function() { } if (!this.timer) { - - if (this.requiresTimeout == true) { this.timer = window.setTimeout(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function }