diff options
Diffstat (limited to 'animism-align/frontend/views/align/components/timeline.component.js')
| -rw-r--r-- | animism-align/frontend/views/align/components/timeline.component.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/animism-align/frontend/views/align/components/timeline.component.js b/animism-align/frontend/views/align/components/timeline.component.js index eb851b7..86175cf 100644 --- a/animism-align/frontend/views/align/components/timeline.component.js +++ b/animism-align/frontend/views/align/components/timeline.component.js @@ -8,6 +8,7 @@ import actions from '../../../actions' import Waveform from './waveform.component' import Ticks from './ticks.component' +import Cursor from './cursor.component' import { ZOOM_STEPS } from '../constants' import { clamp } from '../../../util' @@ -16,6 +17,7 @@ class Timeline extends Component { constructor(props){ super(props) this.handleKeydown = this.handleKeydown.bind(this) + this.handleMouseMove = this.handleMouseMove.bind(this) this.handleWheel = this.handleWheel.bind(this) } componentDidMount() { @@ -40,17 +42,42 @@ class Timeline extends Component { handleWheel(e) { let { start_ts, zoom, duration } = this.props.timeline let secondsPerPixel = ZOOM_STEPS[zoom] * 0.1 // 0.1 sec / step - let widthTimeDuration = window.innerWidth * secondsPerPixel // secs per pixel + let widthTimeDuration = window.innerHeight * secondsPerPixel // secs per pixel start_ts = clamp(start_ts + e.deltaY * ZOOM_STEPS[zoom], 0, Math.max(0, duration - widthTimeDuration / 2)) console.log(start_ts) actions.align.setScrollPosition(start_ts) } + handleMouseMove(e) { + const { start_ts, zoom, duration } = this.props.timeline + const y = e.pageY + const height = window.innerHeight + + let secondsPerPixel = ZOOM_STEPS[zoom] * 0.1 + let widthTimeDuration = height * secondsPerPixel + + let timeMin = start_ts + let timeMax = Math.min(start_ts + widthTimeDuration, duration) + let timeWidth = timeMax - timeMin + + let cursor_ts = y * secondsPerPixel + start_ts + cursor_ts = clamp(cursor_ts, 0, timeMax) + + actions.align.setCursor(cursor_ts) + + // let pixelMin = timeMin / secondsPerPixel + // const ts = + } render() { return ( - <div className='timeline' onWheel={this.handleWheel}> + <div + className='timeline' + onWheel={this.handleWheel} + onMouseMove={this.handleMouseMove} + > <Waveform /> <Ticks timeline={this.props.timeline} /> + <Cursor timeline={this.props.timeline} /> </div> ) } |
