Install react-native-text-ticker
masterInstall the package using npm or yarn:
npm install --save react-native-text-tickeror
yarn add react-native-text-tickernpm install --save react-native-text-tickerrepository·master·Indexed 19 days ago
https://github.com/deanhet/react-native-text-tickerA React Native component that provides marquee-like text scrolling effects. It supports infinite looping, bouncing for slightly oversized text, and manual user scrolling. The library includes the TextTicker and TextMarquee components, allowing for automatic or explicit animation types (auto, scroll, bounce) with customizable speeds, durations, and easing.
Install the package using npm or yarn:
npm install --save react-native-text-tickeror
yarn add react-native-text-tickernpm install --save react-native-text-tickerThe example project uses standard NPM/Yarn scripts to manage development and testing. Use these commands to start the app, run tests, or launch on specific platforms.
npm start: Runs the app in development mode. You can view it in the Expo app on your phone. To clear the packager cache, use npm start -- --reset-cache.npm run ios: Starts the app and attempts to open it in the iOS Simulator (macOS required).npm run android: Starts the app and attempts to open it on a connected Android device or emulator.npm test: Runs the Jest test runner.npm run eject: Starts the permanent process of ejecting from Create React Native App to use native build tools (Xcode/Android Studio) directly.npm start
npm test
npm run ios
npm run android
npm run ejectThe TextTicker component can be used as a drop-in replacement for the standard React Native Text component. It supports a single child text string; using any other children may cause unexpected behavior.
import React, { PureComponent } from 'react'
import { StyleSheet, View } from 'react-native'
import TextTicker from 'react-native-text-ticker'
export default class Example extends PureComponent {
render(){
return(
<View style={styles.container}>
<TextTicker
style={{ fontSize: 24 }}
duration={3000}
loop
bounce
repeatSpacer={50}
marqueeDelay={1000}
>
Super long piece of text is long. The quick brown fox jumps over the lazy dog.
</TextTicker>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});import React, { PureComponent } from 'react'
import { StyleSheet, View } from 'react-native'
import TextTicker from 'react-native-text-ticker'
export default class Example extends PureComponent {
render(){
return(
<View style={styles.container}>
<TextTicker
style={{ fontSize: 24 }}
duration={3000}
loop
bounce
repeatSpacer={50}
marqueeDelay={1000}
>
Super long piece of text is long. The quick brown fox jumps over the lazy dog.
</TextTicker>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});To share your JS-only app via the Expo client app, you can use Expo's free hosting by publishing your project.
exp CLI globally: npm i -g exp.exp publish.npm i -g exp
exp publishIf you are running your project in a virtual machine or need to override the automatically detected IP address, use the REACT_NATIVE_PACKAGER_HOSTNAME environment variable.
Mac and Linux:
REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm startWindows:
set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname'
npm startYou can configure basic app metadata in app.json under the expo key.
expo.name key to your desired string.expo.icon key to a local path or a URL. It is recommended to use a 512x512 PNG file with transparency.{
"expo": {
"name": "Your App Name",
"icon": "./path/to/icon.png"
}
}TextMarquee uses a combination of Animated and ScrollView to manage text movement.
textWidth <= containerWidth, no animation occurs (content fits).distance < containerWidth / 8), it may trigger a bounce animation if bounce is enabled.scroll animation.loop is set to true, the component resets the animatedValue to 0 and restarts the animation sequence once a cycle completes.ScrollView to allow users to manually scroll through the text if scroll is enabled.If npm run ios fails with errors like "non-zero exit code: 107" or claims Xcode is not installed, follow these steps:
Command Line Tools dropdown is set to a valid version. This is a common issue when installing via Homebrew.Reset Contents and Settings... from the app menu, then restart the simulator and re-run the command.If you encounter network timeouts or refused connections when loading the app on a physical device, ensure your phone and computer are on the same network. The packager requires access to ports 19000 and 19001. Verify your firewall settings allow these ports.
To test connectivity, replace the exp:// prefix of the URL printed in your terminal with http:// and attempt to load it in your phone's web browser (e.g., http://192.168.0.1:19000).
If the http URL is unreachable, try using your phone's mobile hotspot to create a network for your computer and restart the packager.
Example URL transformation:
exp://192.168.0.1:19000 -> http://192.168.0.1:19000If the QR code is not scanning:
You can control the animation manually by accessing the component via a ref. The following methods are available:
startAnimation(delay): Starts the animation after the specified delay.stopAnimation(): Stops the animation.The following props are available for the TextTicker component:
| Prop | Type | Optional | Default | Description |
|---|---|---|---|---|
style | StyleObj | true | - | Text Style |
duration | number | true | 150ms * length of string | Number of milliseconds until animation finishes |
bounceSpeed | number | true | 50 | Describes how fast the bounce animation moves. Effective when duration is not set. |
scrollSpeed | number | true | 150 | Describes how fast the scroll animation moves. Effective when duration is not set. |
animationType | string | true | 'auto' | one of the values from 'auto', 'scroll', 'bounce' |
loop | boolean | true | true | Infinitely scroll the text, effective when animationType is 'auto' |
bounce | boolean | true | true | If text is only slightly longer than its container then bounce back/forwards instead of full scroll, effective when animationType is 'auto' |
scroll | boolean | true | true | Gives the ability to grab the text and scroll for the user to read themselves. Will start scrolling again after marqueeDelay or 3000ms |
marqueeOnMount | boolean | true | true | Will start scroll as soon as component has mounted. Disable if using methods instead. |
marqueeDelay | number | true | 0 | Number of milliseconds to wait before starting marquee |
onMarqueeComplete | function | true | - | This function will run after the text has completely passed across the screen. Will run repeatedly if loop is enabled. |
onScrollStart | function | true | - | This function will run if the text is long enough to trigger the scroll. |
isInteraction | boolean | true | true | Whether or not animations create an interaction handle on the InteractionManager. Disable if you are having issues with VirtualizedLists not rendering properly. |
useNativeDriver | boolean | true | true | Use native animation driver, should remain true for large majority of use-cases |
repeatSpacer | number | true | 50 | The space between the end of your text string ticker and the beginning of it starting again. |
bouncePadding | { left: number, right: number } | true | - | The padding on start/end positions of bounce. |
bounceDelay | number | true | 0 | How long the animation should wait after each bounce before starting again. |
easing | function | true | Easing.ease | How the text scrolling animates. Additional options available from the Easing module |
shouldAnimateTreshold | number | true | 0 | If you have a view drawn over the text at the right (a fade-out gradient for instance) this should be set to the width of the overlaying view |
disabled | boolean | true | false | Disables text animation |
isRTL | boolean | true | false | If text is right to left (By default, it uses I18nManager.isRTL to check) |