Git Product home page Git Product logo

react-marquee-text's Introduction

React Marquee Text

MarqueeText is a React component that takes it back to the internet of days gone by. Paying homage to the vintage (and beloved) Marquee element, MarqueeText inserts areas of continuous scrolling text, empowering your retro or brutalist-inspired designs.

Docs / Demo


Contents

  1. πŸ“Œ Features
  2. 🎯 Quickstart
  3. πŸ€– Commands
  4. 🧬 Options
  5. πŸ•ΉοΈ Usage
  6. πŸ““ Notes
  7. πŸ“… To Dos

πŸ“Œ Features

  • Built in Typescript.
  • Creates continous scrolling animations of text.
  • Creates continous loop effect by cloning text to ensure it fills container.
  • Uses CSS animation.
  • Scrolling animation starts / stops when text is in viewport (by default), via Intersection Observer
  • Options to control scrolling direction and duration.

Live Demo→


🎯 Quickstart

Install package from npm

npm i react-marquee-text

Use that thing

import MarqueeText from "react-marquee-text"
import "MarqueeText/styles.css"

function SomeComponent() {
  return (
    <MarqueeText>
      Let's bring it on back to days of yore
    </MarqueeText>
  )
}

Depending on your CSS bundling configuration, you may have to also import MarqueeText's CSS file (which houses the simple @keyframe aniamtion)



πŸ€– Commands

Install npm i react-marquee-text
Build: npm run build
Dev: npm run dev
Demo Run: npm run demo:start
Demo Build: npm run demo:build
Demo Clean: npm run demo:clean

Dev

Runing dev fires up the docs/demo and begins watching src.

The docs/demo app is bundled with Parcel.js and served at http://localhost:1234/.

Dist

On build, src populates dist with commonjs, es, umd versions of the component.


🧬 Options

Option Type Description Default
children sring React children for providing text as string null
className string Defines a parent class name null
direction 'left' | 'right' Direction of scroll animation left
duration number Amount of time it takes for original text to complete animation 50
textSpacing string Spacing between cloned text items 0.15em
pauseOnHover boolean Pauses scroll animation on hover false
playOnlyInView string Only run play animation when component is visible in viewport true
treshold number Intersection Observer value between 0 and 1 representing the percentage component must be visible before stagger animation starts. 0.1
willChange boolean Adds will-change to animation to potential enhance animation performance false

πŸ•ΉοΈ Usage

<MarqueeText
  duration={30}
  pauseOnHover={true}
  direction="right"
>
  This be some right scroll text
</MarqueeText>

πŸ““ Notes

Mostly inlined CSS

The package largely uses inlined CSS. Currently, the @keyframes animation is the only declaration housed in an external CSS file. styles.css is imported into the tsx file, but given your bundle setup, you may, or may not, have to handle that import. If the animation doesn't run immediately, try importing react-marquee-text/styles.css directly in your project.

Supports HTML tags

MarqueeText supports HTML elements, so you can wrap your text in spans or divs to style specific words.


πŸ“… To Dos

  • Add option to control animation based on scroll position.
  • Maybe add some callbacks?
  • Maybe add vertical scrolling option?
  • Run more robust perf tests. Would js / RAF animation or WAAPI be better, esp for multiple instances?
  • Add some proper tests

Have fun ya'll.

react-marquee-text's People

Contributors

ericrallen avatar stephenscaff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

interwebalchemy

react-marquee-text's Issues

HTML tags stopping text from looping

Hello, I have been trying to integrate this into a project and have found that when just using plain text it is fine, but the second I add any html elements, or have multiple items within , it starts with just a few instances of the text and then scrolls off with no more being added.

Here it is working with only plain text:

<MarqueeText direction='right' duration={35} textSpacing='64px'>
      Test
</MarqueeText>

and here are examples that will cause the issue:

<MarqueeText direction='right' duration={35} textSpacing='64px'>
    Test <u>Test2</u>
</MarqueeText>
<MarqueeText direction='right' duration={35} textSpacing='64px'>
     <div>
        Test    
     </div>
</MarqueeText>

Putting within a div or involving any html seems to completely break the looping.

CSS is not inlcuded in npm package

The files array in the package.json is missing the dist/styles.css file, so the marquee animation is unavailable to consumers of the react-marquee-text package.

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.