@@ -4,63 +4,74 @@ import { getActualSource } from '../utils';
44const TRIMMER_COMPONENT_NAME = 'RNTrimmerView' ;
55
66export class Trimmer extends Component {
7- static propTypes = {
8- source : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) . isRequired ,
9- width : PropTypes . number ,
10- height : PropTypes . number ,
11- themeColor : PropTypes . string ,
12- onChange : PropTypes . func ,
13- minLength : PropTypes . number ,
14- maxLength : PropTypes . number ,
15- currentTime : PropTypes . number ,
16- trackerColor : PropTypes . string
17- } ;
7+ static propTypes = {
8+ source : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . number ] ) . isRequired ,
9+ width : PropTypes . number ,
10+ height : PropTypes . number ,
11+ themeColor : PropTypes . string ,
12+ onChange : PropTypes . func ,
13+ onTrackerMove : PropTypes . func ,
14+ minLength : PropTypes . number ,
15+ maxLength : PropTypes . number ,
16+ currentTime : PropTypes . number ,
17+ trackerColor : PropTypes . string
18+ } ;
1819
19- static defaultProps = {
20- themeColor : 'gray' ,
21- trackerColor : 'black'
22- } ;
20+ static defaultProps = {
21+ themeColor : 'gray' ,
22+ trackerColor : 'black'
23+ } ;
2324
24- constructor ( ...args ) {
25- super ( ...args ) ;
26- this . state = { } ;
27- this . _onChange = this . _onChange . bind ( this ) ;
28- }
25+ constructor ( ...args ) {
26+ super ( ...args ) ;
27+ this . state = { } ;
28+ this . _onChange = this . _onChange . bind ( this ) ;
29+ this . _handleTrackerMove = this . _handleTrackerMove . bind ( this ) ;
30+ }
2931
30- _onChange ( event ) {
31- if ( ! this . props . onChange ) {
32- return ;
33- }
34- this . props . onChange ( event . nativeEvent ) ;
35- }
32+ _onChange ( event ) {
33+ if ( ! this . props . onChange ) {
34+ return ;
35+ }
36+ this . props . onChange ( event . nativeEvent ) ;
37+ }
3638
37- render ( ) {
38- const {
39- source,
39+ _handleTrackerMove ( { nativeEvent } ) {
40+ const { onTrackerMove } = this . props ;
41+ const { currentTime } = nativeEvent ;
42+ if ( typeof onTrackerMove === 'function' ) {
43+ onTrackerMove ( { currentTime } ) ;
44+ }
45+ }
46+
47+ render ( ) {
48+ const {
49+ source,
4050 width,
4151 height,
4252 themeColor,
4353 minLength,
4454 maxLength,
4555 currentTime,
4656 trackerColor
47- } = this . props ;
48- const actualSource = getActualSource ( source ) ;
49- return (
50- < RNTrimmer
51- source = { actualSource }
52- width = { width }
53- height = { height }
54- currentTime = { currentTime }
55- themeColor = { processColor ( themeColor ) . toString ( ) }
56- trackerColor = { processColor ( trackerColor ) . toString ( ) }
57- pointerEvents = { 'box-none' }
58- onChange = { this . _onChange }
59- minLength = { minLength }
60- maxLength = { maxLength }
61- />
62- ) ;
63- }
57+ } = this . props ;
58+ const actualSource = getActualSource ( source ) ;
59+ return (
60+ < RNTrimmer
61+ source = { actualSource }
62+ width = { width }
63+ height = { height }
64+ currentTime = { currentTime }
65+ themeColor = { processColor ( themeColor ) . toString ( ) }
66+ trackerColor = { processColor ( trackerColor ) . toString ( ) }
67+ onTrackerMove = { this . _handleTrackerMove }
68+ pointerEvents = { 'box-none' }
69+ onChange = { this . _onChange }
70+ minLength = { minLength }
71+ maxLength = { maxLength }
72+ />
73+ ) ;
74+ }
6475}
6576
6677const RNTrimmer = requireNativeComponent ( TRIMMER_COMPONENT_NAME , Trimmer ) ;
0 commit comments