summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/paragraph/containers/paragraphList.container.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-06 19:54:33 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-06 19:54:33 +0200
commitbeac05596a0d09e07087c326224160db6fd1e936 (patch)
tree85dd46da1b04937b51b366c7f4437c126633ac46 /animism-align/frontend/views/paragraph/containers/paragraphList.container.js
parent67db33081c3272ee75e2a3d8f08c0373e0687438 (diff)
set paragraph end with specific element
Diffstat (limited to 'animism-align/frontend/views/paragraph/containers/paragraphList.container.js')
-rw-r--r--animism-align/frontend/views/paragraph/containers/paragraphList.container.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/animism-align/frontend/views/paragraph/containers/paragraphList.container.js b/animism-align/frontend/views/paragraph/containers/paragraphList.container.js
index 8b61df5..600eaad 100644
--- a/animism-align/frontend/views/paragraph/containers/paragraphList.container.js
+++ b/animism-align/frontend/views/paragraph/containers/paragraphList.container.js
@@ -7,7 +7,7 @@ import actions from '../../../actions'
import { ParagraphElementLookup } from '../components/paragraph.types'
const floatLT = (a,b) => ((a*10|0) < (b*10|0))
-const floatLTE = (a,b) => (a*10|0 === b*10|0 || floatLT(a,b))
+const floatLTE = (a,b) => ((a*10|0) === (b*10|0) || floatLT(a,b))
class ParagraphList extends Component {
state = {
@@ -29,13 +29,19 @@ class ParagraphList extends Component {
}
setCurrentParagraph() {
const { play_ts } = this.props.audio
- this.state.paragraphs.some(paragraph => {
+ const insideParagraph = this.state.paragraphs.some(paragraph => {
if (floatLTE(paragraph.start_ts, play_ts) && floatLT(play_ts, paragraph.end_ts)) {
this.setCurrentAnnotation(paragraph, play_ts)
return true
}
return false
})
+ if (!insideParagraph) {
+ this.setState({
+ currentParagraph: -1,
+ currentAnnotation: -1,
+ })
+ }
}
setCurrentAnnotation(paragraph, play_ts) {
const { id: currentParagraph, annotations } = paragraph
@@ -80,10 +86,12 @@ class ParagraphList extends Component {
}
})
for (let i = 0; i < (paragraphs.length - 1); i++) {
+ console.log(paragraphs[i].end_ts)
if (!paragraphs[i].end_ts) {
paragraphs[i].end_ts = paragraphs[i+1].start_ts - 0.1
}
}
+ console.log(paragraphs)
this.setState({ paragraphs })
}
onAnnotationClick(e, paragraph, annotation){