kyo504 / react-native-marquee

React Native Marquee Text Component
MIT License
201 stars 31 forks source link

show static text instead when text fits within container #7

Closed bluenex closed 6 years ago

bluenex commented 6 years ago

I faced the problem when the text fits in container width. In that case I want the text just align on center by {textAlign: 'center'}. However this.setState({ animating: true }); is called even before this.calculateMetrics(); thus the static text with center aligned opacity is set to 0 and show ScrollView instead.

This PR aims to solve this by calling this.setState({ animating: true }); after contentFits is known. And if contentFits is true, instead of animating it, just leave it as is and call

this.stop();
onMarqueeComplete();

after duration passed.

Disclaimer

I don't actually test this because setting up environment is somehow not convenient and the paths in the index.js are entangled. So please test before accept or reject. If there is more time I will create PR for testing locally.