-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.js
51 lines (44 loc) · 1.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { Component } from 'react';
import {
View,
requireNativeComponent,
ViewPropTypes
} from 'react-native';
import { bool, string, number, array, shape, arrayOf } from 'prop-types';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
class ImageSequence extends Component {
render() {
let normalized = this.props.images.map(resolveAssetSource);
// reorder elements if start-index is different from 0 (beginning)
if (this.props.startFrameIndex !== 0) {
normalized = [...normalized.slice(this.props.startFrameIndex), ...normalized.slice(0, this.props.startFrameIndex)];
}
return (
<RCTImageSequence
{...this.props}
images={normalized} />
);
}
}
ImageSequence.defaultProps = {
startFrameIndex: 0,
framesPerSecond: 24,
loop: true
};
ImageSequence.propTypes = {
startFrameIndex: number,
images: array.isRequired,
framesPerSecond: number,
loop: bool
};
const RCTImageSequence = requireNativeComponent('RCTImageSequence', {
propTypes: {
...ViewPropTypes,
images: arrayOf(shape({
uri: string.isRequired
})).isRequired,
framesPerSecond: number,
loop: bool
},
});
export default ImageSequence;