diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-07-08 15:58:49 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-07-08 15:58:49 +0200 |
| commit | 2b8cf9e695414eb19104ab8bbff64673842b4202 (patch) | |
| tree | 60e2f4d2f6c8820e4812df99689a3738a39158c8 /animism-align/frontend/views/align | |
| parent | bbcf48825bec60dab7a4de955bc4831eadb37792 (diff) | |
fix timeline util issue
Diffstat (limited to 'animism-align/frontend/views/align')
| -rw-r--r-- | animism-align/frontend/views/align/align.util.js | 27 | ||||
| -rw-r--r-- | animism-align/frontend/views/align/containers/timeline.container.js | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/animism-align/frontend/views/align/align.util.js b/animism-align/frontend/views/align/align.util.js index d7b4c39..91af64c 100644 --- a/animism-align/frontend/views/align/align.util.js +++ b/animism-align/frontend/views/align/align.util.js @@ -31,17 +31,22 @@ export const timeToPosition = (ts, { start_ts, zoom, duration }) => { } export const getFirstPunctuationMarkIndex = text => { - return Math.min( - text.indexOf('. '), - text.indexOf('? '), - text.indexOf('! '), - text.indexOf('." '), - text.indexOf('?" '), - text.indexOf('!" '), - text.indexOf('.” '), - text.indexOf('?” '), - text.indexOf('!” '), - ) + 1 + const indexes = [ + text.indexOf('. '), + text.indexOf('? '), + text.indexOf('! '), + text.indexOf('." '), + text.indexOf('?" '), + text.indexOf('!" '), + text.indexOf('.” '), + text.indexOf('?” '), + text.indexOf('!” '), + ] + + return indexes.reduce((a, b) => { + if (b < 0) return a + return Math.min(a, b) + }, Infinity) + 1 } export const cutFirstSentence = text => { diff --git a/animism-align/frontend/views/align/containers/timeline.container.js b/animism-align/frontend/views/align/containers/timeline.container.js index ba6b7e0..69f2496 100644 --- a/animism-align/frontend/views/align/containers/timeline.container.js +++ b/animism-align/frontend/views/align/containers/timeline.container.js @@ -85,7 +85,7 @@ class Timeline extends Component { let { deltaY } = e let secondsPerPixel = ZOOM_STEPS[zoom] * 0.1 // 0.1 sec / step let widthTimeDuration = INNER_HEIGHT * secondsPerPixel // secs per pixel - start_ts += Math.round((deltaY / 8) * ZOOM_STEPS[zoom]) + start_ts += Math.round((deltaY) * ZOOM_STEPS[zoom]) start_ts = clamp(start_ts, 0, Math.max(0, duration - widthTimeDuration / 2)) if (e.shiftKey) { if (Math.abs(deltaY) < 2) return |
