New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pietile-carousel

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pietile-carousel

React Carousel

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213
decreased by-9.36%
Maintainers
1
Weekly downloads
 
Created
Source

React carousel which tries to minimize amount of repaints and be simple in use.

Features

  • Doesn't require to specify items dimensions (pure css solution)
  • Tries to rely on translates as much as possible for movements (zero paints in best cases)
  • Arbitary number of visible items
  • Сyclicality

Usage

Every item is wrapped in container where it can layout it's content. The size of container depends on the size of carousel and amount of visible items. You can use any styling system you want to set styles. Get ref and user moveLeft/moveRight/moveTo methods for scroll.

Example

import React, { useRef, useEffect } from 'react';

import PietileCarousel from 'PietileCarousel';

function App() {
  const carousel = useRef(null);

  useEffect(() => {
    const interval = setInterval(() => {
      if (!carousel.current) {
        return;
      }

      carousel.current.moveLeft();
    }, 1000);

    return () => {
      clearInterval(interval);
    };
  });

  const carouselStyle = {
    width: 150,
    height: 100,
  };

  const itemStyle = {
    width: '100%',
    height: '100%',
  };

  return (
    <PietileCarousel ref={carousel} style={carouselStyle}>
      <div style={{ ...itemStyle, backgroundColor: 'red' }} />
      <div style={{ ...itemStyle, backgroundColor: 'orange' }} />
      <div style={{ ...itemStyle, backgroundColor: 'yellow' }} />
    </PietileCarousel>
  );
}

API

Properties

namedescriptiontypedefault
childrenComponents rendered in carousel (required)Node-
classNameCSS classstring-
countAmount of visible itemsnumber1
marginMargin between itemsnumber0
styleStyle objectObject-
onChangeCallback when index changesFunction-

Methods

namedescription
moveLeft()Scroll left
moveRight()Scroll left
scrollTo(index)Scroll to index

License

Pietile Carousel is MIT License.

FAQs

Package last updated on 13 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc