Closed levicki closed 6 years ago
Which is a duplicate of #46, an almost four year old issue. Is it impossible to fix?
I see Raymond's comment about browser rendering the text and uMatrix not knowing it will be cut, but it seems to be possible to check the text width in pixels by using invisible DIV:
https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript
I am not sure how much that would slow the rendering though?
A clean solution would be adding a title
attribute whenever the host name exceeds a certain length.
<div title="bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com" class="matCell ....">
<b>bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com</b>
</div>
Well it turns out that in HTML5 you can use canvas to measure text width:
function getTextWidth(text, font) {
// if given, use cached canvas for better performance
// else, create new canvas
var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
var context = canvas.getContext("2d");
context.font = font;
var metrics = context.measureText(text);
return metrics.width;
};
...
getTextWidth("bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com", "bold 12pt arial");
This shouldn't slow down the popup, @gorhill what do you think Raymond?
Host names like this:
bw-1651cf0d2f737d7adeab84d339dbabd3-bcs.s3.amazonaws.com
Result in matrix which looks like this:
In my opinion,, either those names should be shortened to something like:
bw-1...3-bcs.s3.amazonaws.com
And the mouseover should show the full name in tooltip, or the matrix column with host name should expand itself to fit.
Browser is Chrome, but I observed this with Firefox too. If you need more information, please let me know.