Fix node label size calculation

This commit is contained in:
Nick O'Leary 2019-05-21 23:48:33 +01:00
parent 359c0354f6
commit 9ed3a6748a
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 4 additions and 9 deletions

View File

@ -1759,15 +1759,10 @@ RED.view = (function() {
}
function calculateTextDimensions(str,className,offsetW,offsetH) {
var sp = document.createElement("span");
sp.className = className;
sp.style.position = "absolute";
sp.style.top = "-1000px";
sp.textContent = (str||"");
document.body.appendChild(sp);
var w = sp.offsetWidth;
var h = sp.offsetHeight;
document.body.removeChild(sp);
var sp = $('<span>',{class: className,style: "position: absolute; top: -1000px"}).text(str||"").appendTo("#red-ui-editor");
var w = sp.width();
var h = sp.height();
sp.remove();
return [offsetW+w,offsetH+h];
}