feat(bidirectional) Allow text callouts to be linked to the short axis of the bidirectional tool (#44)

This commit is contained in:
Bruno Alves de Faria 2018-07-03 07:31:41 -03:00 committed by Erik Ziegler
parent b8d619390a
commit 303c94c3b0

View File

@ -7,7 +7,7 @@ import updatePerpendicularLineHandles from '../updatePerpendicularLineHandles';
import drawPerpendicularLine from './drawPerpendicularLine'; import drawPerpendicularLine from './drawPerpendicularLine';
import drawSelectedMarker from './drawSelectedMarker'; import drawSelectedMarker from './drawSelectedMarker';
export default function(event) { export default function onImageRendered(event) {
const eventData = event.detail; const eventData = event.detail;
const { element, canvasContext } = eventData; const { element, canvasContext } = eventData;
@ -44,7 +44,7 @@ export default function(event) {
const data = toolData.data[i]; const data = toolData.data[i];
if (data.visible === false) continue; if (data.visible === false) continue;
const { start, end, textBox } = data.handles; const { start, end, perpendicularStart, perpendicularEnd, textBox } = data.handles;
const strokeWidth = lineWidth; const strokeWidth = lineWidth;
context.save(); context.save();
@ -130,9 +130,14 @@ export default function(event) {
end: {} end: {}
}; };
const midpointCanvas = { const longLine = {
x: (handleStartCanvas.x + handleEndCanvas.x) / 2, start: handleStartCanvas,
y: (handleStartCanvas.y + handleEndCanvas.y) / 2, end: handleEndCanvas
};
const perpendicularLine = {
start: handlePerpendicularStartCanvas,
end: handlePerpendicularEndCanvas
}; };
// Check if the perpendicular line has some length (start and end are not equal) // Check if the perpendicular line has some length (start and end are not equal)
@ -196,4 +201,4 @@ export default function(event) {
context.restore(); context.restore();
} }
} }