### Install react-native-text-ticker using npm or yarn
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/README.md
This snippet shows how to add the react-native-text-ticker package to your project using either npm or yarn package managers.
```bash
npm install --save react-native-text-ticker
or
yarn add react-native-text-ticker
```
--------------------------------
### Build and Run React Native App on iOS Simulator
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This command builds and attempts to launch the React Native application on the iOS Simulator. It requires a macOS environment with Xcode installed. It's typically used during development for testing on iOS.
```bash
npm run ios
```
--------------------------------
### Troubleshooting iOS Simulator Errors in React Native
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This section outlines steps to resolve common errors when running `npm run ios` on a Mac, including Xcode installation, command-line tools configuration, and resetting the simulator's content and settings.
```bash
npm run ios
```
```bash
yarn run ios
```
--------------------------------
### Basic TextTicker Component Example (JSX)
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
Demonstrates the basic usage of the TextTicker component. It renders scrolling text that animates horizontally when the content exceeds the container width. The component automatically detects if scrolling is needed and selects the appropriate animation type.
```jsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function BasicExample() {
return (
Super long piece of text is long. The quick brown fox jumps over the lazy dog.
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
```
--------------------------------
### Eject from Create React Native App
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
Eject from Create React Native App to gain full control over native code, allowing you to build and deploy your app using Xcode and Android Studio. This process typically involves running an eject script and installing react-native-cli.
```bash
# Eject from CRNA
npm run eject
# Ensure react-native-cli is installed and follow native code guides
npm install -g react-native-cli
```
--------------------------------
### Handle Text Ticker Animation Events with Callbacks
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
This snippet shows how to use `onMarqueeComplete` and `onScrollStart` props to trigger functions when the text ticker animation completes a cycle or starts, respectively. It requires React Native and react-native-text-ticker.
```jsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function EventCallbacksExample() {
const handleScrollStart = () => {
console.log('Scroll animation started!');
// Track analytics, update UI state, etc.
};
const handleMarqueeComplete = () => {
console.log('Scroll completed one full cycle!');
// Increment counter, trigger next action, etc.
};
return (
Breaking news: This ticker will fire callbacks as it scrolls across the screen!
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', padding: 20 },
ticker: { fontSize: 16 },
});
```
--------------------------------
### Add Flow for Static Type Checking
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
Integrate Flow, a static type checker, into your Create React Native App project. This involves installing the correct flow-bin version, updating package.json scripts, and adding '// @flow' to files for type checking.
```bash
# Install flow-bin matching .flowconfig version
npm install --save-dev flow-bin@x.y.z
# or
yarn add --dev flow-bin@x.y.z
```
```json
// Add to package.json scripts section
"scripts": {
"flow": "flow"
}
```
```javascript
// Add to the top of files to enable type checking
// @flow
```
```bash
# Run flow type checking
npm run flow
# or
yarn flow
```
--------------------------------
### Disabled State and User Scroll Interaction with React Native Text Ticker
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
Illustrates controlling the animation's disabled state using the `disabled` prop and enabling/disabling manual user scrolling with the `scroll` prop. Includes examples with `Switch` components for dynamic control.
```jsx
import React, { useState } from 'react';
import { View, Switch, Text, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function DisabledAndScrollExample() {
const [isDisabled, setIsDisabled] = useState(false);
const [allowScroll, setAllowScroll] = useState(true);
return (
Disabled:
Allow Manual Scroll:
This is a long scrolling text. When scroll is enabled, you can grab and drag it manually. It will resume auto-scrolling after marqueeDelay.
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', padding: 20 },
controls: { flexDirection: 'row', alignItems: 'center', marginBottom: 20, gap: 10 },
ticker: { fontSize: 16 },
});
```
--------------------------------
### Enable Text Ticker Animation with Overlay Views using Threshold
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
This example demonstrates the `shouldAnimateTreshold` prop, which is useful when overlay views partially obscure the text. Setting this prop ensures the animation triggers even if the text would otherwise appear to fit within the visible area. It requires React Native and react-native-text-ticker.
```jsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function ThresholdExample() {
const overlayWidth = 40;
return (
{/* Without threshold - text may not animate even though it's obstructed */}
This fits but there's a view at the right obstructing the end.
{/* With threshold - accounts for overlay width */}
This fits but there's a view at the right obstructing the end.
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', padding: 20 },
tickerContainer: { marginBottom: 20, height: 20 },
overlay: {
position: 'absolute',
top: 0,
bottom: 0,
right: 0,
opacity: 0.8,
},
});
```
--------------------------------
### Build and Run React Native App on Android Device/Emulator
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This command builds and attempts to launch the React Native application on a connected Android device or emulator. It requires Android build tools and an emulator like Genymotion to be set up.
```bash
npm run android
```
--------------------------------
### Publish to Expo's React Native Community
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
Share your JS-only app through the Expo client app by publishing it to Expo's hosting service. This requires an Expo account and the 'exp' command-line tool.
```bash
# Install exp command-line tool globally
npm i -g exp
# Publish your app
exp publish
```
--------------------------------
### Run Jest Tests in React Native
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This command executes the Jest test runner to execute all tests defined within the project. Jest is a popular JavaScript testing framework used for unit and integration testing.
```bash
npm test
```
--------------------------------
### Troubleshooting Network Connectivity with React Native Packager URLs
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This snippet demonstrates how to verify network connectivity for React Native development by accessing packager URLs via a web browser. It helps diagnose issues where the Expo app cannot connect to the development server.
```text
exp://192.168.0.1:19000
```
```text
http://192.168.0.1:19000
```
```text
http://192.168.0.1:19001
```
--------------------------------
### Eject from Create React Native App
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This command initiates the process of ejecting from Create React Native App's build configuration. This is a permanent action that requires setting up native development environments like Xcode and Android Studio.
```bash
npm run eject
```
--------------------------------
### Configure App Display Name and Icon in app.json
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
Modify the app.json file to set the application's display name and icon. The 'expo.name' key controls the display name, and 'expo.icon' can be a local path or URL for the app icon. It's recommended to use a 512x512 PNG with transparency for the icon.
```json
{
"expo": {
"name": "Your App Name",
"icon": "./assets/icon.png"
}
}
```
--------------------------------
### Basic Usage of TextTicker in React Native
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/README.md
Demonstrates how to import and use the TextTicker component as a replacement for the standard React Native Text component. It includes common props like duration, loop, bounce, and repeatSpacer for customizing the scrolling behavior.
```javascript
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(
Super long piece of text is long. The quick brown fox jumps over the lazy dog.
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
```
--------------------------------
### Restart Packager Cache in React Native
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
This command restarts the React Native packager, clearing its cache. This is useful when encountering issues with hot reloading or build errors. It can be executed using either npm or yarn.
```bash
npm start -- --reset-cache
yarn start -- --reset-cache
```
--------------------------------
### Manual TextTicker Animation Control with Refs (JSX)
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
Shows how to programmatically control the TextTicker animation using refs. The `marqueeOnMount` prop is set to `false` to prevent automatic animation on component mount. Functions `handleStart` and `handleStop` are provided to control the animation via touchable opacity components.
```jsx
import React, { useRef } from 'react';
import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function ManualControlExample() {
const tickerRef = useRef(null);
const handleStart = () => {
tickerRef.current?.startAnimation(500); // Start with 500ms delay
};
const handleStop = () => {
tickerRef.current?.stopAnimation();
};
return (
Start Animation
Stop Animation
Super long piece of text is long. The quick brown fox jumps over the lazy dog.
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
button: { padding: 10, marginVertical: 5, backgroundColor: '#ddd' },
ticker: { fontSize: 18, marginTop: 20 },
});
```
--------------------------------
### TextTicker Animation Type Configuration (JSX)
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
Illustrates how to configure the animation behavior of the TextTicker component using the `animationType` prop. Options include 'auto' for intelligent selection, 'scroll' for continuous scrolling, and 'bounce' for back-and-forth movement. Various props are shown for customizing each animation type.
```jsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function AnimationTypesExample() {
return (
{/* Auto mode - chooses scroll or bounce based on overflow amount */}
This text will bounce if slightly longer, or scroll if much longer
{/* Force scroll animation */}
This text always scrolls continuously regardless of length
{/* Force bounce animation */}
This text bounces back and forth from side to side
);
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 20 },
ticker: { fontSize: 18, marginVertical: 10 },
});
```
--------------------------------
### Configure Packager IP Address using Environment Variable
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/example/README.md
Override the default packager IP address or hostname detected by Create React Native App by setting the REACT_NATIVE_PACKAGER_HOSTNAME environment variable. This is useful when running the project in environments like virtual machines.
```bash
# Mac and Linux
REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
```
```bash
# Windows
set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname'
npm start
```
--------------------------------
### Custom Easing Functions with React Native Text Ticker
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
Demonstrates how to customize animation curves using the `easing` prop with functions from React Native's Easing module. Supports linear, ease-in-out, and bounce effects.
```jsx
import React from 'react';
import { View, StyleSheet, Easing } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function CustomEasingExample() {
return (
{/* Linear easing - constant speed */}
Linear easing - smooth constant speed scrolling text animation
{/* Ease in-out - smooth acceleration and deceleration */}
Ease in-out - accelerates at start, decelerates at end
{/* Bounce easing effect */}
Bounce easing - creates a bouncy feel to the animation
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', padding: 20 },
ticker: { fontSize: 16, marginVertical: 15 },
});
```
--------------------------------
### Text Ticker Animation Control
Source: https://github.com/deanhet/react-native-text-ticker/blob/master/README.md
Control the animation of the text ticker component using its ref.
```APIDOC
## Text Ticker Animation Control
### Description
These methods are optional and can be accessed by accessing the ref of the TextTicker component to control its animation.
### Method
Access via component ref
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Methods Available via Ref
#### `startAnimation(delay?: number)`
- **delay** (number) - Optional - The delay in milliseconds before starting the animation.
- **Description**: Starts the text animation.
#### `stopAnimation()`
- **Description**: Stops the text animation.
### Request Example
```javascript
// Assuming you have a ref to the TextTicker component
const tickerRef = useRef(null);
// To start animation with a 500ms delay
tickerRef.current.startAnimation(500);
// To stop animation
tickerRef.current.stopAnimation();
```
### Response
#### Success Response (N/A)
These methods do not return a value, they control the component's state.
#### Response Example
N/A
```
--------------------------------
### Configure Text Ticker for RTL Support
Source: https://context7.com/deanhet/react-native-text-ticker/llms.txt
This snippet illustrates how to enable Right-to-Left (RTL) text direction for the text ticker using the `isRTL` prop. It can be set to `true` to force RTL or left to default behavior, which uses React Native's `I18nManager.isRTL`. This is essential for languages like Arabic or Hebrew. Requires React Native and react-native-text-ticker.
```jsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import TextTicker from 'react-native-text-ticker';
export default function RTLExample() {
return (
{/* Force RTL direction */}
هذا نص طويل جداً يتحرك من اليمين إلى اليسار
{/* Auto-detect RTL based on device settings */}
This will automatically use device RTL settings
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', padding: 20 },
ticker: { fontSize: 18, marginVertical: 10 },
});
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.