1.2.0 • Published 4 years ago

react-overflow-scroll v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

React Overflow Scroll

react-overflow-slider gotobutton styles

Built with react hooks, styled-components and lodash

  • horizontal scrollbar
  • lazy loading images!!
  • touch support
  • grabbing and clicking
  • smooth scrolling
  • clickable navigation dots
  • universal app support
  • customizable styles
  • and more...

Quick start

yarn add (or npm install) --save react-overflow-scroll

In project:

import React from "react";
import ReactDOM from "react-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
  faChevronRight,
  faChevronLeft
} from "@fortawesome/free-solid-svg-icons";
import Slider from "react-overflow-scroll";

const App = () => {
  let arrayItems = [...Array(19).keys()].map((el, index) => (
    <div
      style={{ height: 200, minWidth: 200, background: "#eee", margin: 8 }}
      key={index}
    >
      Lorem ipsum!
    </div>
  ));
  const arrowRight = <FontAwesomeIcon icon={faChevronRight} />;
  const arrowLeft = <FontAwesomeIcon icon={faChevronLeft} />;

  return (
    <>
      <div style={{ width: 950 }}>
        <Slider
          data={arrayItems}
          arrowLeft={arrowLeft}
          arrowRight={arrowRight}
          withGrab={true}
          withDots={true}
        />
      </div>
    </>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));

Properties and callbacks

PropsTypeDescription
dataArray components / imagesItems to render in slider
sliderStyleObjectStyles for slider
buttonStyleObjectStyles for buttons
withArrowsBooleanRender clickable arrows
withGrabBooleanAllow moving slider by grabbing items
withDotsBooleanRender dots that shows number ofactual slide
withGrabBooleanAllow moving slider by grabbing items
withScaleStringZoom in or zoom out items while slider move
arrowLeftReact componentReact component for left arrow
arrowRightReact componentReact component for right arrow
scrollToClickBooleanEnable scrolling to specified item
scrollToChildNumberWhich child should scroll to when ScrollToClick is true
scrollByNumberScroll by specific amount of items

Lazy loading

React-overflow-scroll helps optimize your aplication by loading images only as they enter the viewport. It is written in vanilla JavaScript so it makes package lightweight. Make sure to provide data-set as img attribute.

Example:

<img alt="lazy image" data-src="lazy.jpg" />

Lazy loading will not work correctly with withDots, so make sure to to switch it off.

Styles

Include width propery in sliderStyle prop or in parent's element.

Gotchas

It is not recommended to use navigation dots on mobile. The will not follow slider. Ignore them in props because by default they are hidden or set withDots={false} in props.

Usage examples

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.11

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago