From 84c96287f35e31c90f1e9ae15d333ad1df86542f Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 5 Jan 2014 18:57:47 -0300 Subject: [PATCH] Hack Chrome text element issue. --- web2d/src/main/javascript/peer/svg/TextPeer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web2d/src/main/javascript/peer/svg/TextPeer.js b/web2d/src/main/javascript/peer/svg/TextPeer.js index f7ec4d7c..24fb8ba9 100644 --- a/web2d/src/main/javascript/peer/svg/TextPeer.js +++ b/web2d/src/main/javascript/peer/svg/TextPeer.js @@ -153,9 +153,16 @@ web2d.peer.svg.TextPeer = new Class({ }, getWidth : function () { + var computedWidth; // Firefox hack for this issue:http://stackoverflow.com/questions/6390065/doing-ajax-updates-in-svg-breaks-getbbox-is-there-a-workaround try { - var computedWidth = this._native.getBBox().width; + computedWidth = this._native.getBBox().width; + // Chrome bug is producing this error, oly during page loading. Remove the hack if it works. The issue seems to be + // caused when the element is hidden. + if(computedWidth==0){ + computedWidth = getBoundingClientRect().width - 35; + } + } catch(e) { computedWidth = 10; }