Dim events on timeline in narrative mode

This commit is contained in:
Franc Camps-Febrer
2019-01-07 08:25:32 +01:00
parent 8fe6600c67
commit 7168cd10f1
2 changed files with 22 additions and 6 deletions

View File

@@ -256,6 +256,7 @@ class Timeline extends React.Component {
/>
<TimelineEvents
events={this.props.domain.events}
narrative={this.props.app.narrative}
getEventX={(e) => this.getEventX(e)}
getEventY={(e) => this.getEventY(e)}
getCategoryColor={this.props.methods.getCategoryColor}

View File

@@ -1,6 +1,6 @@
import React from 'react';
const TimelineEvents = ({ events, getEventX, getEventY,
const TimelineEvents = ({ events, narrative, getEventX, getEventY,
getCategoryColor, onSelect, transitionDuration }) => {
function getAllEventsAtOnce(eventPoint) {
@@ -11,17 +11,32 @@ const TimelineEvents = ({ events, getEventX, getEventY,
}
function renderEvent(event) {
let styleProps = ({
fill: getCategoryColor(event.category),
fillOpacity: 0.8,
transform: `translate(${getEventX(event)}px, ${getEventY(event)}px)`,
transition: `transform ${transitionDuration / 1000}s ease`
});
if (narrative) {
const { steps } = narrative
const isInNarrative = steps.map(s => s.id).includes(event.id)
if (!isInNarrative) {
styleProps = {
...styleProps,
fillOpacity: 0.1
}
}
}
return (
<circle
className="event"
cx={0}
cy={0}
style={{
'transform': `translate(${getEventX(event)}px, ${getEventY(event)}px)`,
'transition': `transform ${transitionDuration / 1000}s ease`
}}
style={styleProps}
r={5}
fill={getCategoryColor(event.category)}
onClick={() => {onSelect(getAllEventsAtOnce(event))}}
>
</circle>