Skip to content

Commit d6af0e3

Browse files
committed
feat(tools): If entries in availableTools include a mode, this will be their initial setting
1 parent 95badde commit d6af0e3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-cornerstone-viewport",
3-
"version": "0.1.21",
3+
"version": "0.1.22",
44
"description": "Cornerstone medical image viewport component for React",
55
"author": "Cornerstone Contributors",
66
"license": "MIT",

src/CornerstoneViewport/CornerstoneViewport.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function setToolsPassive(cornerstoneTools, tools) {
2121
});
2222
}
2323

24+
function capitalizeFirstLetter(string) {
25+
return string.charAt(0).toUpperCase() + string.slice(1);
26+
}
27+
2428
function initializeTools(cornerstoneTools, tools, element) {
2529
Array.from(tools).forEach(tool => {
2630
const apiTool = cornerstoneTools[`${tool.name}Tool`] || tool.apiTool;
@@ -29,6 +33,13 @@ function initializeTools(cornerstoneTools, tools, element) {
2933
} else {
3034
throw new Error(`Tool not found: ${tool.name}Tool`);
3135
}
36+
37+
if (tool.mode) {
38+
cornerstoneTools[`setTool${capitalizeFirstLetter(tool.mode)}ForElement`](
39+
element,
40+
tool.name
41+
);
42+
}
3243
});
3344
}
3445

0 commit comments

Comments
 (0)