on master help sign in
Fix size analysis of text in IE and FireFox
5fbc042evancz
core-js/Graphics/Element.js+6−6
@@ -223,29 +223,29 @@ ElmCode.Graphics.Element = function() {
223 function heightOf_53(e) { return ~~e[4]; }
223 function heightOf_53(e) { return ~~e[4]; }
224 function sizeOf_54(e) { return["Tuple2", ~~e[3], ~~e[4]] }
224 function sizeOf_54(e) { return["Tuple2", ~~e[3], ~~e[4]] }
225 function text_56(txt) {
225 function text_56(txt) {
226− var p = Value.getTextSize(-1,-1,txt);
226+ var p = Value.getTextSize(0,0,txt);
227 return basicNewElement(EText_39("left")(txt), p[0], p[1])
227 return basicNewElement(EText_39("left")(txt), p[0], p[1])
228 }
228 }
229 function plainText(str) {
229 function plainText(str) {
230 var txt = Value.toText(str);
230 var txt = Value.toText(str);
231− var p = Value.getTextSize(-1,-1,txt);
231+ var p = Value.getTextSize(0,0,txt);
232 return basicNewElement(EText_39("left")(txt),p[0],p[1])
232 return basicNewElement(EText_39("left")(txt),p[0],p[1])
233 }
233 }
234 function asText(v) {
234 function asText(v) {
235 var txt = Value.show(v);
235 var txt = Value.show(v);
236− var p = Value.getTextSize(-1,-1,txt);
236+ var p = Value.getTextSize(0,0,txt);
237 return basicNewElement(EText_39("left")(txt),p[0],p[1])
237 return basicNewElement(EText_39("left")(txt),p[0],p[1])
238 }
238 }
239 function centeredText(txt) {
239 function centeredText(txt) {
240− var p = Value.getTextSize(-1,-1,txt);
240+ var p = Value.getTextSize(0,0,txt);
241 return basicNewElement(EText_39("center")(txt),p[0],p[1])
241 return basicNewElement(EText_39("center")(txt),p[0],p[1])
242 }
242 }
243 function justifiedText(txt) {
243 function justifiedText(txt) {
244− var p = Value.getTextSize(-1,-1,txt);
244+ var p = Value.getTextSize(0,0,txt);
245 return basicNewElement(EText_39("justify")(txt),p[0],p[1])
245 return basicNewElement(EText_39("justify")(txt),p[0],p[1])
246 }
246 }
247 function rightedText(txt) {
247 function rightedText(txt) {
248− var p = Value.getTextSize(-1,-1,txt);
248+ var p = Value.getTextSize(0,0,txt);
249 return basicNewElement(EText_39("right")(txt),p[0],p[1])
249 return basicNewElement(EText_39("right")(txt),p[0],p[1])
250 }
250 }
251 function image_57(w) {
251 function image_57(w) {
core-js/Value.js+3−3
@@ -81,8 +81,8 @@ var Value = function(){
81 function getTextSize(w,h,txt) {
81 function getTextSize(w,h,txt) {
82 var t = document.createElement('div');
82 var t = document.createElement('div');
83 t.innerHTML = txt;
83 t.innerHTML = txt;
84+ t.style.textAlign = 'left';
84− t.style.width = w + "px";
85+ if (w > 0) { t.style.width = w + "px"; }
85− //t.style.height = h + 'px';
86
86
87 t.style.visibility = "hidden";
87 t.style.visibility = "hidden";
88 t.style.styleFloat = "left";
88 t.style.styleFloat = "left";
@@ -94,7 +94,7 @@ var Value = function(){
94 var realH = cStyle.getPropertyValue("height").slice(0,-2) - 0;
94 var realH = cStyle.getPropertyValue("height").slice(0,-2) - 0;
95 document.body.removeChild(t);
95 document.body.removeChild(t);
96 delete t;
96 delete t;
97− return [realW,Math.max(h,realH)];
97+ return [Math.ceil(realW),Math.ceil(Math.max(h,realH))];
98 }
98 }
99
99
100 function getSize(e) {
100 function getSize(e) {