Restructuring bidirectionalTool to improve maintainability

This commit is contained in:
Bruno Alves de Faria committed 2017-12-28 08:59:25 -02:00
1 parent 4aa0204119
commit 0acdff0bc5
22 files changed
+1290 -1

No files matched your search

@@ -0,0 +1,40 @@
import { toolType } from './definitions';
const getHandle = (x, y, index, extraAttributes={}) => {
return Object.assign({
x,
y,
index,
drawnIndependently: false,
allowedOutsideImage: false,
highlight: true,
active: false
}, extraAttributes);
};
export default function(mouseEventData) {
const { x, y } = mouseEventData.currentPoints.image;
// Create the measurement data for this tool with the end handle activated
const measurementData = {
toolType,
isCreating: true,
visible: true,
active: true,
handles: {
start: getHandle(x, y, 0),
end: getHandle(x, y, 1, { active: true }),
perpendicularStart: getHandle(x, y, 2, { locked: true }),
perpendicularEnd: getHandle(x, y, 3),
textBox: getHandle(x - 50, y - 70, 4, {
movesIndependently: false,
drawnIndependently: true,
allowedOutsideImage: true,
hasBoundingBox: true
})
},
longestDiameter: 0,
shortestDiameter: 0
};
return measurementData;
}