fix: calculate text dimensions after wrapping message text

This commit is contained in:
Johnny Walker 2020-12-11 20:20:37 -05:00
parent 0103da13f0
commit 469a726285
1 changed files with 2 additions and 1 deletions

View File

@ -969,7 +969,6 @@ const buildMessageModel = function(msg, actors) {
const toIdx = fromBounds[0] < toBounds[0] ? 0 : 1;
const allBounds = fromBounds.concat(toBounds);
const boundedWidth = Math.abs(toBounds[toIdx] - fromBounds[fromIdx]);
const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf));
if (msg.wrap && msg.message) {
msg.message = utils.wrapLabel(
msg.message,
@ -977,6 +976,8 @@ const buildMessageModel = function(msg, actors) {
messageFont(conf)
);
}
const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf));
return {
width: Math.max(
msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding,