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/align.util.js | |
| parent | bbcf48825bec60dab7a4de955bc4831eadb37792 (diff) | |
fix timeline util issue
Diffstat (limited to 'animism-align/frontend/views/align/align.util.js')
| -rw-r--r-- | animism-align/frontend/views/align/align.util.js | 27 |
1 files changed, 16 insertions, 11 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 => { |
