Reputation: 2351
I am using videojs in my react application and I want to achieve something like this:
Things I have are :
What I want
Problem:
What I tried till now (but obviously it is wrong)
tags.map((item, i) => {
if( item.time <= currentTime <= item.stopTime){
this.props.markerReachedAction(i);
}
})
How can I do it?
Upvotes: 0
Views: 102
Reputation: 573
Please use the condition with two implicit comparisons conjoined by an &&
i.e.
if (item.time <= currentTime && currentTime <= item.stopTime)
Review the following snippet to see what is the problem. 1 < 3 < 2 should be false but it is computed as true.
$('#a').html('Result of 1 < 3 < 2 = ' + 1 < 3 < 2);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="a"></div>
Since the value is being continuously updated and you need to perform the computation continuously as well. You should use setInterval along with clearInterval. There are examples of usage on the reference link that you may use.
Upvotes: 1