npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-advanced-news-ticker

v1.0.1

Published

<h1 align="center">React Advanced News Ticker</h1>

Downloads

2,387

Readme

alt text

A powerful, flexible and animated vertical news ticker plugin for React. React Advanced News Ticker provides multiple callbacks and methods to allow a maximum flexibility and an easy implementation into any project.

🏠 Demo

⚡️ Quickstart

<NewsTicker>
  <div>Etiam imperdiet volutpat libero eu tristique.</div>
  <div>Curabitur porttitor ante eget hendrerit adipiscing.</div>
  <div>Praesent ornare nisl lorem, ut condimentum lectus gravida ut.</div>
  <div>Nunc ultrices tortor eu massa placerat posuere.</div>
</NewsTicker>

⚙️ Installation

npm i react-advanced-news-ticker

👀 Examples

📖 With Custom Props

<NewsTicker
    rowHeight = {48}
    maxRows = {2}
    speed = {600}
    direction = {Directions.UP}
    duration = {4000}
    autoStart = {true}
    pauseOnHover = {false}
    id = "myId"
    className = "myClassName1 myClassName2"
    style = {{marginTop: 34}}>
    <div>Etiam imperdiet volutpat libero eu tristique.</div>
    <div>Curabitur porttitor ante eget hendrerit adipiscing.</div>
    <div>Praesent ornare nisl lorem, ut condimentum lectus gravida ut.</div>
    <div>Nunc ultrices tortor eu massa placerat posuere.</div>
</NewsTicker>

📖 With Callbacks

const updateInfos = () => {
  ...
}

return <NewsTicker
    maxRows = {1}
    duration = {6000}
    hasMoved = {updateInfos}
    started = {()=>{
      console.log('react advanced news ticker just started!');
    }}
    paused = {()=>{
      console.log('react advanced news ticker has been paused.');
    }}>
    <div>Etiam imperdiet volutpat libero eu tristique.</div>
    <div>Curabitur porttitor ante eget hendrerit adipiscing.</div>
    <div>Praesent ornare nisl lorem, ut condimentum lectus gravida ut.</div>
    <div>Nunc ultrices tortor eu massa placerat posuere.</div>
</NewsTicker>

📖 With Methods

const newsTickerRef = useRef(null);
return <>
  <NewsTicker
      ref = {newsTickerRef}
      autoStart = {false}
      speed = {400}>
      <div>Etiam imperdiet volutpat libero eu tristique.</div>
      <div>Curabitur porttitor ante eget hendrerit adipiscing.</div>
      <div>Praesent ornare nisl lorem, ut condimentum lectus gravida ut.</div>
      <div>Nunc ultrices tortor eu massa placerat posuere.</div>
  </NewsTicker>

  <button
    onClick={() => { newsTickerRef.current.start() }}>
    Start
  </button>

  <div
    onMouseEnter={() => newsTickerRef.current.pause()}
    onMouseLeave={() => newsTickerRef.current.unPause()}>
     Pause
  </div>
</>

📇 Props

| Prop | Usage | Type/Values | Default value | | -------------- | ----------------------------------------------------------------------------------------- | ------------------------------------ | ---------------- | | rowHeight | defines the height (in px) of one row | int | 22 | | maxRows | defines the number of rows displayed at the same time | int | 3 | | speed | defines the animation speed (in ms)of the rows moving up or down | int (in ms) | 400 | | duration | defines the times (in ms) before the rows automatically move | int (in ms) | 2500 | | direction | defines the direction of the rows movement | Directions.UP or Directions.DOWN | Directions.UP | | autoStart | enable/disable auto start on load | bool | true | | pauseOnHover | enable/disable pause when mouse hovers the newsTicker element | bool | true | | className | for define className of newsTicker's ul element | bool | true | | id | for define id of newsTicker's ul element | bool | "" | | style | for styling newsTicker's ul element | object | {} | | hasMoved | callback called at the end of every movement animation | function | | movingUp | callback called before launching moving up action | function | | movingDown | callback called before launching moving down action | function | | start | callback called on start action | function | | stop | callback called on stop action | function | | pause | callback called on pause action (triggered on onMouseEnter if pauseOnHover=true ) | function | | unpause | called on unpause action (triggered on onMouseLeave if pauseOnHover=true ) | function |

📇 Methods

After creating NewsTicker component with ref, methods are called with ref.current.methodName()

Example :

ref.current.stop();
ref.current.start();
ref.current.move();
ref.current.getState();
ref.current.pause();

📜 Method List

| Method | Action | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | start | starts moving newsTicker elements | | stop | stops moving newsTicker elements | | getState | returns current state: TickerStates.Stopped = stopped, TickerStates.Running = started, TickerStates.Paused = paused (and started) | | pause | pauses newsTicker elements without stopping them - the newsTicker has to be started to be able to pause it (the pause method is called on onMouseEnter if pauseOnHover = true) | | unpause | unpauses newsTicker elements - the newsTicker has to be started & paused to be able to unpause it (the unpause method is called on onMouseLeave if pauseOnHover = true) | | moveDown | moves elements down | | moveUp | moves elements up | | moveNext | moves up or down according to the current direction option | | movePrev | moves up or down according to the current direction option | | move | equivalent to moveNext, but will not move if paused |

Author

👤 Ahmet Can Aydemir

👍 Contribute

Contributions, issues and feature requests are welcome!Feel free to check issues page.

📝 License

This project based on risq's JQuery Advanced News Ticker. This project is GPL-2.0 licensed.