From 3e5bc2f5581890f2d7d9f679ab5171c0637ff460 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 5 Jul 2020 17:02:39 +0200 Subject: notion of selected annotation --- .../components/annotations/annotation.index.js | 15 ++++++++++---- .../components/annotations/annotation.types.js | 23 +++++++++++++--------- .../components/timeline/waveform.component.js | 4 ++-- 3 files changed, 27 insertions(+), 15 deletions(-) (limited to 'animism-align/frontend/views/align/components') diff --git a/animism-align/frontend/views/align/components/annotations/annotation.index.js b/animism-align/frontend/views/align/components/annotations/annotation.index.js index 09cb255..9117a80 100644 --- a/animism-align/frontend/views/align/components/annotations/annotation.index.js +++ b/animism-align/frontend/views/align/components/annotations/annotation.index.js @@ -41,18 +41,24 @@ class AnnotationIndex extends Component { }).map(id => lookup[id]).reverse() this.setState({ items }) } - handleClick(annotation) { + handleClick(e, annotation) { actions.audio.seek(annotation.start_ts) + actions.align.setSelectedAnnotation(annotation.id) } - handleDoubleClick(annotation) { + handleDoubleClick(e, annotation) { actions.align.showEditAnnotationForm(annotation) } render() { const { timeline } = this.props - const { start_ts } = timeline + const { start_ts, zoom, selected_annotation_id } = timeline const { items } = this.state + const className = (zoom < 2) + ? 'annotationIndex' + : (zoom < 3) + ? 'annotationIndex condensed' + : 'annotationIndex collapsed' return ( -
+
{items.map(annotation => { const { id, type, start_ts } = annotation const AnnotationElement = AnnotationElementLookup[type] @@ -61,6 +67,7 @@ class AnnotationIndex extends Component { { - const { start_ts, text } = annotation +export const AnnotationSentence = ({ y, annotation, selected, onClick, onDoubleClick }) => { + const { start_ts, text, paragraph_id } = annotation + let className = (paragraph_id % 2) + ? 'annotation sentence odd' + : 'annotation sentence even' + if (selected) className += ' selected' return (
onClick(annotation)} - onDoubleClick={() => onDoubleClick(annotation)} + onClick={e => onClick(e, annotation)} + onDoubleClick={e => onDoubleClick(e, annotation)} > {text}
) } -export const AnnotationHeader = ({ y, annotation, onClick, onDoubleClick }) => { +export const AnnotationHeader = ({ y, annotation, selected, onClick, onDoubleClick }) => { const { start_ts, text } = annotation + const className = selected ? 'annotation header selected' : 'annotation header' return (
onClick(annotation)} - onDoubleClick={() => onDoubleClick(annotation)} + onClick={e => onClick(e, annotation)} + onDoubleClick={e => onDoubleClick(e, annotation)} > {text}
diff --git a/animism-align/frontend/views/align/components/timeline/waveform.component.js b/animism-align/frontend/views/align/components/timeline/waveform.component.js index 0a118cf..785b020 100644 --- a/animism-align/frontend/views/align/components/timeline/waveform.component.js +++ b/animism-align/frontend/views/align/components/timeline/waveform.component.js @@ -48,8 +48,8 @@ class Waveform extends Component { let widthTimeDuration = h * secondsPerPixel // secs per pixel - let timeMin = start_ts - let timeMax = Math.min(start_ts + widthTimeDuration, duration) + let timeMin = Math.round(start_ts / secondsPerPixel) * secondsPerPixel + let timeMax = Math.min(timeMin + widthTimeDuration, duration) let timeWidth = timeMax - timeMin let stepMin = Math.floor(timeMin * 10) -- cgit v1.2.3-70-g09d2