diff --git a/src/components/presentational/Map/Narratives.jsx b/src/components/presentational/Map/Narratives.jsx index 4424900..9e9f9e4 100644 --- a/src/components/presentational/Map/Narratives.jsx +++ b/src/components/presentational/Map/Narratives.jsx @@ -1,5 +1,7 @@ import React from 'react' import { Portal } from 'react-portal' +import { concatStatic } from 'rxjs/operator/concat'; +import { single } from 'rxjs/operator/single'; function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, projectPoint }) { function getNarrativeStyle (narrativeId) { @@ -61,7 +63,29 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, function _renderNarrativeStep (p1, p2, styles) { const { stroke, strokeWidth, strokeDasharray, strokeOpacity } = styles + const distance = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)) + const theta = Math.atan2(p2.y - p1.y, p2.x - p1.x) // Angle of narrative step line + const alpha = Math.atan2(1, 2) // Angle of arrow overture + const edge = 10 // Arrow edge length + const offset = (distance < 24) ? distance / 2 : 24; + + // Arrow corners + const coord0 = { + x: p2.x - offset * Math.cos(theta), + y: p2.y - offset * Math.sin(theta) + } + const coord1 = { + x: coord0.x - edge * Math.cos(-theta - alpha), + y: coord0.y + edge * Math.sin(-theta - alpha) + } + const coord2 = { + x: coord0.x - edge * Math.cos(-theta + alpha), + y: coord0.y + edge * Math.sin(-theta + alpha) + } + + return ( + + {(stroke !== 'none') + ? () + : '' + } + ) } diff --git a/src/scss/map.scss b/src/scss/map.scss index 72d0506..5b78777 100644 --- a/src/scss/map.scss +++ b/src/scss/map.scss @@ -175,6 +175,10 @@ stroke-width: 0; } +.narrative-step-arrow { + pointer-events: all !important; +} + .path-polyline { stroke: $darkgrey; stroke-width: 2px;