react-jw-player
Advanced tools
Comparing version 1.8.0-alpha.4 to 1.8.0-alpha.5
@@ -7,4 +7,3 @@ "use strict"; | ||
function onAdTime(event) { | ||
var _state$previousPositi = this.state.previousPositionInteger, | ||
previousPositionInteger = _state$previousPositi === undefined ? 0 : _state$previousPositi; | ||
var previousPositionInteger = this.state.previousPositionInteger; | ||
var position = event.position; | ||
@@ -18,20 +17,9 @@ | ||
var shouldUpdateState = false; | ||
this.props.onEverySecond(currentPositionInteger); | ||
if (currentPositionInteger === 0) { | ||
shouldUpdateState = true; | ||
} | ||
if (currentPositionInteger > previousPositionInteger) { | ||
this.props.onEverySecond(currentPositionInteger); | ||
shouldUpdateState = true; | ||
} | ||
if (shouldUpdateState) { | ||
this.setState({ | ||
previousPositionInteger: currentPositionInteger | ||
}); | ||
} | ||
this.setState({ | ||
previousPositionInteger: currentPositionInteger | ||
}); | ||
} | ||
exports.default = onAdTime; |
{ | ||
"name": "react-jw-player", | ||
"version": "1.8.0-alpha.4", | ||
"version": "1.8.0-alpha.5", | ||
"description": "A React component for launching JW Player instances on the client.", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-jw-player.js", |
function onAdTime(event) { | ||
const { previousPositionInteger = 0 } = this.state; | ||
const { previousPositionInteger } = this.state; | ||
const { position } = event; | ||
@@ -10,20 +10,9 @@ const currentPositionInteger = Math.floor(position); | ||
let shouldUpdateState = false; | ||
this.props.onEverySecond(currentPositionInteger); | ||
if (currentPositionInteger === 0) { | ||
shouldUpdateState = true; | ||
} | ||
if (currentPositionInteger > previousPositionInteger) { | ||
this.props.onEverySecond(currentPositionInteger); | ||
shouldUpdateState = true; | ||
} | ||
if (shouldUpdateState) { | ||
this.setState({ | ||
previousPositionInteger: currentPositionInteger, | ||
}); | ||
} | ||
this.setState({ | ||
previousPositionInteger: currentPositionInteger, | ||
}); | ||
} | ||
export default onAdTime; |
@@ -32,3 +32,3 @@ import test from 'tape'; | ||
t.doesNotThrow(onAdTime.bind(null, mockEvent), 'it runs without error'); | ||
t.deepEqual(results.onEverySecondCallCount, 0, 'it does not invoke onEverySecond() prop on initial call'); | ||
t.deepEqual(results.onEverySecondCallCount, 1, 'it does invokes onEverySecond() prop on initial call'); | ||
@@ -38,3 +38,3 @@ mockEvent.position = 1; | ||
t.doesNotThrow(onAdTime.bind(null, mockEvent), 'it runs without error one second later'); | ||
t.deepEqual(results.onEverySecondCallCount, 1, 'it invoke onEverySecond() prop at one second'); | ||
t.deepEqual(results.onEverySecondCallCount, 2, 'it invoke onEverySecond() prop at one second'); | ||
t.deepEqual(mockComponent.state.previousPositionInteger, 1, 'stores 1 as previous position'); | ||
@@ -45,3 +45,3 @@ | ||
t.doesNotThrow(onAdTime.bind(null, mockEvent), 'it runs without error one second later'); | ||
t.deepEqual(results.onEverySecondCallCount, 2, 'it invoke onEverySecond() prop at two seconds'); | ||
t.deepEqual(results.onEverySecondCallCount, 3, 'it invoke onEverySecond() prop at two seconds'); | ||
t.deepEqual(mockComponent.state.previousPositionInteger, 2, 'stores 2 as previous position'); | ||
@@ -48,0 +48,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86610
2069