Skip to content

Commit

Permalink
feat: Adding digits configuration for Length tool (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoalvesdefaria authored Aug 25, 2021
1 parent 41352cc commit 9333b63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tools/annotation/LengthTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class LengthTool extends BaseAnnotationTool {
drawHandlesOnHover: false,
hideHandlesIfMoving: false,
renderDashed: false,
digits: 2,
},
};

Expand Down Expand Up @@ -146,6 +147,7 @@ export default class LengthTool extends BaseAnnotationTool {
drawHandlesOnHover,
hideHandlesIfMoving,
renderDashed,
digits,
} = this.configuration;
const toolData = getToolState(evt.currentTarget, this.name);

Expand Down Expand Up @@ -252,7 +254,7 @@ export default class LengthTool extends BaseAnnotationTool {
function textBoxText(annotation, rowPixelSpacing, colPixelSpacing) {
const measuredValue = _sanitizeMeasuredValue(annotation.length);

// measured value is not defined, return empty string
// Measured value is not defined, return empty string
if (!measuredValue) {
return '';
}
Expand All @@ -266,7 +268,7 @@ export default class LengthTool extends BaseAnnotationTool {

annotation.unit = suffix;

return `${measuredValue.toFixed(2)} ${suffix}`;
return `${measuredValue.toFixed(digits)} ${suffix}`;
}

function textBoxAnchorPoints(handles) {
Expand Down

0 comments on commit 9333b63

Please sign in to comment.