3.4.1 • Published 2 years ago

@guna81/react-ticker v3.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Ticker

A simple and customizable react ticker (news scroller) component.

Installation

Install with npm

  npm install @guna81/react-ticker

Demo

Checkout the Demo.

Usage/Examples

export default function App() {
  const data = [
    {
      id: 1,
      value:
        "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
    },
    // more data ...
  ];

  const renderItem = (item) => {
    return (
      <p style={{ whiteSpace: "nowrap", color: "orange" }} >
        {item.value}
      </p>
    );
  };

  return (
    <div className="App">

      {/* using default ticker item component */}
      <ReactTicker
        data={data.map((item) => item.value)}
        speed={20}
        keyName="_id"
        tickerStyle={{
          position: "fixed",
          top: 0,
          left: "0",
          width: "100%",
          height: "40px",
          backgroundColor: "#fff",
          zIndex: 99,
          borderTop: "1px solid #e0e0e0"
        }}
        tickerClassName="news-ticker"
      />
      
      {/* using custom ticker item component */}
      <ReactTicker
        data={data}
        component={renderItem}
        speed={40}
        keyName="_id"
        tickerStyle={{
          position: "fixed",
          bottom: 0,
          left: "0",
          width: "100%",
          height: "40px",
          backgroundColor: "#fff",
          zIndex: 99,
          borderTop: "1px solid #e0e0e0"
        }}
        tickerClassName="news-ticker"
      />
    </div>
  );
}

API Reference

Props

ParameterTypeDescriptionDefault Value
dataarrayRequired. List of objects or strings.empty array
componentreact nodeCustom ticker item component.null
keyNamestringKey of object (Required, if only the data is a list of objects.).null
speednumberScroll speed (0 - 60).30
delaynumberScroll delay.0
diretionstringScroll direction.normal
tickerClassNamestringTicker container class name.empty string
itemClassNamestringTicker item class name.empty string
tickerTextClassNamestringTicker text class name (Required, if only the data is a list of strings).empty string
tickerStyleobjectTicker container style.empty object
itemStyleobjectTicker item styles.empty object
loopbooleanInfinite scroll.true
  • Component and keyName props are required if data is a list of objects.
  • If data is a list of strings, components, and keyName props are unnecessary.
3.4.0

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.4.1

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.2.8

2 years ago

2.2.7

2 years ago

2.2.6

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago