summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/align/components/timeline/cursorRegion.component.js
blob: cce20012ca9e94153b632eb2965d423df804c6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React, { Component } from 'react'

import { ZOOM_STEPS } from 'app/constants'
import { timestamp } from 'app/utils'

const CursorRegion = ({ timeline }) => {
  const { start_ts, zoom, cursor_region } = timeline
  if (!cursor_region) return null
  const secondsPerPixel = ZOOM_STEPS[zoom] * 0.1
  const duration = cursor_region.b_ts - cursor_region.a_ts
  const y = (cursor_region.a_ts - start_ts) / secondsPerPixel
  const height = (duration) / secondsPerPixel
  return (
    <div
      className='cursor_region'
      style={{
        top: y,
        height,
      }}
    >
      <div className='tickLabel'>
        {timestamp(duration, 1, true)}
      </div>
    </div>
  )
}

export default CursorRegion