From 6373c1321cb680de9e354e1e03a11394e532254d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 14 Oct 2020 16:49:07 +0200 Subject: select a region --- .../views/align/containers/timeline.container.js | 41 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'animism-align/frontend/app/views/align/containers/timeline.container.js') diff --git a/animism-align/frontend/app/views/align/containers/timeline.container.js b/animism-align/frontend/app/views/align/containers/timeline.container.js index 3db658c..0cf49f8 100644 --- a/animism-align/frontend/app/views/align/containers/timeline.container.js +++ b/animism-align/frontend/app/views/align/containers/timeline.container.js @@ -9,19 +9,25 @@ import Waveform from 'app/views/align/components/timeline/waveform.component' import Ticks from 'app/views/align/components/timeline/ticks.component' import Cursor from 'app/views/align/components/timeline/cursor.component' import PlayCursor from 'app/views/align/components/timeline/playCursor.component' +import CursorRegion from 'app/views/align/components/timeline/cursorRegion.component' import { WAVEFORM_SIZE, ZOOM_STEPS, INNER_HEIGHT } from 'app/constants' import { clamp } from 'app/utils' import { positionToTime } from 'app/utils/align.utils' class Timeline extends Component { + state = { + dragging: false, + a_ts: -1, + } constructor(props){ super(props) this.handleKeydown = this.handleKeydown.bind(this) this.handleMouseMove = this.handleMouseMove.bind(this) this.handleWheel = this.handleWheel.bind(this) this.handleContainerClick = this.handleContainerClick.bind(this) - this.handleTimelineClick = this.handleTimelineClick.bind(this) + this.handleTimelineMouseDown = this.handleTimelineMouseDown.bind(this) + this.handleTimelineMouseUp = this.handleTimelineMouseUp.bind(this) } componentDidMount() { this.bind() @@ -117,15 +123,32 @@ class Timeline extends Component { actions.align.setScrollPosition(start_ts) } } - handleMouseMove(e) { - const cursor_ts = positionToTime(e.pageY, this.props.timeline) - actions.align.setCursor(cursor_ts) - } handleContainerClick(e) { actions.align.clearSelectedAnnotation() actions.align.clearSelectedParagraph() } - handleTimelineClick(e) { + handleTimelineMouseDown(e) { + const cursor_ts = positionToTime(e.pageY, this.props.timeline) + actions.align.clearCursorRegion() + actions.align.setCursor(cursor_ts) + this.setState({ + dragging: true, + a_ts: cursor_ts, + }) + } + handleMouseMove(e) { + const cursor_ts = positionToTime(e.pageY, this.props.timeline) + if (this.state.dragging) { + actions.align.setCursorRegion( + Math.min(this.state.a_ts, cursor_ts), + Math.max(this.state.a_ts, cursor_ts), + ) + } else { + actions.align.setCursor(cursor_ts) + } + } + handleTimelineMouseUp(e) { + this.setState({ dragging: false }) const play_ts = positionToTime(e.pageY, this.props.timeline) if (e.metaKey) { actions.align.spliceTime(play_ts) @@ -144,9 +167,13 @@ class Timeline extends Component { onMouseMove={this.handleMouseMove} >
- + +
-- cgit v1.2.3-70-g09d2