Giter Site home page Giter Site logo

react-native-text-ticker's Introduction

react-native-text-ticker

Screenshot

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={style.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',
  },
});

Properties

Prop Type Optional Default Description
style StyleObj true - Text Style
duration number true 150ms * length of string Number of milliseconds until animation finishes
scrollingSpeed number true 50 Describes how fast the bounce animation moves. Effective when duration is not set. When effective, the duration will depends on the width of text and screen width
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.
easing function true Easing.ease How the text scrolling animates. Additional options available from the Easing module

Methods

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

Prop Params Description
startAnimation delay Start animation
stopAnimation - Stop animation

License

MIT License

react-native-text-ticker's People

Contributors

aklein13 avatar ansonyao avatar dctalbot avatar eapbachman avatar is343 avatar jm-david avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.