1.14.0 • Published 3 years ago

react-native-text-ticker v1.14.0

Weekly downloads
3,700
License
MIT
Repository
github
Last release
3 years ago

react-native-text-ticker

Screenshot

examples

examples

Description

Inspired from the great react-native-marquee, this module acts similarly but with a few extra features and props:

  • Don't scroll the text if it fits in the container
  • Infinitely scroll text in a ticker fashion
  • Bounce text from side to side if it's only slightly wider than its container
  • Grab the text and scroll it manually

To see it in action check out the example!

This package aims to only support the latest version of React-Native.

Installation

npm install --save react-native-text-ticker
or
yarn add react-native-text-ticker

Usage

This module can be used as a drop in replacement for the react-native Text component (extra props optional).

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',
  },
});

react-native-text-ticker supports a single child text string, any other use may give unexpected behaviour.

Properties

PropTypeOptionalDefaultDescription
styleStyleObjtrue-Text Style
durationnumbertrue150ms * length of stringNumber of milliseconds until animation finishes
bounceSpeednumbertrue50Describes how fast the bounce animation moves. Effective when duration is not set.
scrollSpeednumbertrue150Describes how fast the scroll animation moves. Effective when duration is not set.
animationTypestringtrue'auto'one of the values from 'auto', 'scroll', 'bounce'
loopbooleantruetrueInfinitely scroll the text, effective when animationType is 'auto'
bouncebooleantruetrueIf text is only slightly longer than its container then bounce back/forwards instead of full scroll, effective when animationType is 'auto'
scrollbooleantruetrueGives the ability to grab the text and scroll for the user to read themselves. Will start scrolling again after marqueeDelay or 3000ms
marqueeOnMountbooleantruetrueWill start scroll as soon as component has mounted. Disable if using methods instead.
marqueeDelaynumbertrue0Number of milliseconds to wait before starting marquee
onMarqueeCompletefunctiontrue-This function will run after the text has completely passed across the screen. Will run repeatedly if loop is enabled.
onScrollStartfunctiontrue-This function will run if the text is long enough to trigger the scroll.
isInteractionbooleantruetrueWhether or not animations create an interaction handle on the InteractionManager. Disable if you are having issues with VirtualizedLists not rendering properly.
useNativeDriverbooleantruetrueUse native animation driver, should remain true for large majority of use-cases
repeatSpacernumbertrue50The 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.
bounceDelaynumbertrue0How long the animation should wait after each bounce before starting again.
easingfunctiontrueEasing.easeHow the text scrolling animates. Additional options available from the Easing module
shouldAnimateTresholdnumbertrue0If 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: examples
disabledbooleantruefalseDisables text animation
isRTLbooleantruefalseIf text is right to left (By default, it uses I18nManager.isRTL to check)

Methods

These methods are optional and can be accessed by accessing the ref:

PropParamsDescription
startAnimationdelayStart animation
stopAnimation-Stop animation

License

MIT License

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.9.0

4 years ago

1.10.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

5 years ago

0.20.0

5 years ago

0.19.0

5 years ago

0.18.0

5 years ago

0.17.0

5 years ago

0.16.0

5 years ago

0.15.0

5 years ago

0.14.0

5 years ago

0.13.0

6 years ago

0.12.0

6 years ago

0.11.0

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago