react-native-awesome-marquee
Advanced tools
Comparing version 1.0.9 to 1.1.0
57
index.js
@@ -1,10 +0,5 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import React, { Component } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { | ||
StyleSheet, | ||
View, | ||
Easing, | ||
Animated, | ||
} from 'react-native'; | ||
import { StyleSheet, View, Easing, Animated, Text } from "react-native"; | ||
@@ -15,3 +10,3 @@ class Marquee extends Component { | ||
this.state = { | ||
height: 0, | ||
height: 0 | ||
}; | ||
@@ -32,3 +27,3 @@ this.animatedTransformY = new Animated.Value(0); | ||
toValue: -this.state.height / 2, | ||
easing: Easing.linear, | ||
easing: Easing.linear | ||
}).start(() => this.runAnimation()); | ||
@@ -39,3 +34,3 @@ } | ||
this.setState({ | ||
height: Math.round(e.nativeEvent.layout.height), | ||
height: Math.round(e.nativeEvent.layout.height) | ||
}); | ||
@@ -45,9 +40,21 @@ } | ||
render() { | ||
const { | ||
children, | ||
} = this.props; | ||
const { children, data } = this.props; | ||
const cloneChildren = React.Children.map(children, children => React.cloneElement(children)); | ||
const reactElementArr = [children, cloneChildren]; | ||
let contentCom = []; | ||
if (children) { | ||
contentCom = children; | ||
} else { | ||
contentCom = data.map((item, index) => ( | ||
<View key={`marqueeList${index}`}> | ||
<Text>{item}</Text> | ||
</View> | ||
)); | ||
} | ||
const cloneChildren = React.Children.map(contentCom, contentCom => | ||
React.cloneElement(contentCom) | ||
); | ||
const reactElementArr = [contentCom, cloneChildren]; | ||
return ( | ||
@@ -57,8 +64,6 @@ <View style={[styles.container, { height: this.props.height }]}> | ||
style={{ | ||
transform: [{ translateY: this.animatedTransformY }], | ||
transform: [{ translateY: this.animatedTransformY }] | ||
}} | ||
> | ||
<View | ||
onLayout={(event) => this.wrapperOnLayout(event)} | ||
> | ||
<View onLayout={event => this.wrapperOnLayout(event)}> | ||
{reactElementArr.map(reactEle => reactEle)} | ||
@@ -72,7 +77,6 @@ </View> | ||
const styles = StyleSheet.create({ | ||
container: { | ||
overflow: 'hidden', | ||
}, | ||
overflow: "hidden" | ||
} | ||
}); | ||
@@ -85,4 +89,4 @@ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]).isRequired, | ||
PropTypes.node | ||
]) | ||
}; | ||
@@ -92,6 +96,5 @@ | ||
duration: 10000, | ||
height: 100, | ||
height: 100 | ||
}; | ||
export default Marquee; |
{ | ||
"name": "react-native-awesome-marquee", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Awesome marquee", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# react-native-awesome-marquee | ||
pr# react-native-awesome-marquee | ||
@@ -19,40 +19,69 @@ [![MIT](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/ryanyu104/react-native-awesome-marquee/ryanyu104/master/LICENSE.md) | ||
```javascript | ||
import React, { Component } from 'react'; | ||
import Marquee from "react-native-awesome-marquee" | ||
import React, { Component } from "react"; | ||
import Marquee from "react-native-awesome-marquee"; | ||
const data=[ | ||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.', | ||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.', | ||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.', | ||
] | ||
const data = [ | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.", | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.", | ||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium." | ||
]; | ||
class Example extends Component { | ||
constructor(props) { | ||
super(props) | ||
super(props); | ||
} | ||
renderMarqueeList(){ | ||
return data.map(item,index)=>( | ||
<View key=`${marqueeList${index}}`> | ||
<Text>{item}</Text> | ||
</View> | ||
) | ||
} | ||
render() { | ||
return ( | ||
<View> | ||
<Marquee | ||
duration={20000} | ||
height={100} | ||
> | ||
{this.renderMarqueeList()} | ||
</Marquee> | ||
<View style={styles.applicationView}> | ||
<StatusBar barStyle="light-content" /> | ||
<Marquee duration={20000} height={200}> | ||
<View> | ||
<Text> | ||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean | ||
commodo ligula eget dolor. Aenean massa. Cum sociis natoque | ||
penatibus et magnis dis parturient montes, nascetur ridiculus mus. | ||
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, | ||
sem. Nulla consequat massa quis enim. Donec pede justo, fringilla | ||
vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, | ||
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede | ||
mollis pretium.(children) | ||
</Text> | ||
</View> | ||
<View> | ||
<Text> | ||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean | ||
commodo ligula eget dolor. Aenean massa. Cum sociis natoque | ||
penatibus et magnis dis parturient montes, nascetur ridiculus mus. | ||
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, | ||
sem. Nulla consequat massa quis enim. Donec pede justo, fringilla | ||
vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, | ||
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede | ||
mollis pretium.(children) | ||
</Text> | ||
</View> | ||
<View> | ||
<Text> | ||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean | ||
commodo ligula eget dolor. Aenean massa. Cum sociis natoque | ||
penatibus et magnis dis parturient montes, nascetur ridiculus mus. | ||
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, | ||
sem. Nulla consequat massa quis enim. Donec pede justo, fringilla | ||
vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, | ||
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede | ||
mollis pretium.(children) | ||
</Text> | ||
</View> | ||
</Marquee> | ||
<ReduxNavigation /> | ||
</View> | ||
) | ||
); | ||
} | ||
} | ||
``` | ||
### Notice | ||
When you pass data to Marquee, you don't need to pass React.children, You can only choose one from the data and children. | ||
### Options | ||
@@ -65,1 +94,2 @@ | ||
| children | array(element) | null | Custom multiple elements | | ||
| data | array(string) | null | Marquee elements | |
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
8364
78
94