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-spring-3d-carousel-2

v1.0.1

Published

A 3D Carousel component for images built with React and utilizing react-spring for controlling slide transitions.

Downloads

28

Readme

react-spring-3d-carousel

A 3D Carousel component for images built with React and utilizing react-spring for controlling slide transitions. It's primarily meant to be controlled via the goToSlide prop but I also provided a showNavigation prop if you don't feel like making your own navigation.

This should go without saying, but if you use this component make sure to test it for performance and compatability with your target browsers.

Example

Edit react-spring-3d-carousel-basic-example

Installation and usage

Install it via npm:

npm i react-spring-3d-carousel

or yarn:

yarn add react-spring-3d-carousel

Then import the Carousel component like so :

import Carousel from 'react-spring-3d-carousel';

The only thing this component needs to run is an array of slides, which are objects with a unique key property and a content property containing an image instance :

const slides = [
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/800/?random" alt="1" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/800/?random" alt="2" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/600/800/?random" alt="3" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/500/?random" alt="4" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/800/?random" alt="5" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/500/800/?random" alt="6" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/600/?random" alt="7" />
  },
  {
    key: uuidv4(),
    content: <img src="https://picsum.photos/800/800/?random" alt="8" />
  }
];

...

<Carousel slides={slides} />

And you're all set. You can also use props for better control of how the carousel looks and behaves:

Props

| Name | Default value | Description | | --------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | slides | --- | An array containing elements of the form { key, content, onClick? } where key holds any unique value and content holds a reference to a JSX <img /> to be displayed. onClick is an optional property that may be used to pass a callback method which will be invoked when the slide is clicked. | | goToSlide | null | Setting this prop will cause the carousel to animate towards the provided index in the slides array. If showNavigation is set to false this prop is how you're expected to control the carousel. | | goToSlideDelay | 200 | The amount of milliseconds to delay each slide before moving to the next one while animating towards the index provided in goToSlide. | | offsetRadius | 2 | Number of carousel elements to display to the sides of the current slide, this value is clamped between 1 and Math.floor(slides.length/2), and defaults to 2 when it's possible (if there are enough slide elements). | | animationConfig | { tension: 120, friction: 14 } | A config object passed to the slides' Spring element to control the nature of their animation, for more information check the react-spring docs. | | opacity | null | A numeric value for opacity css property. The value should be between 0 to 1. It changes the opacity of slides. | | autoPlay | false | A boolean value for autoPlay. | | interval | 1 | Numeric value is to be given in terms of seconds(i.e: interval={3} for 3 sec delay between the sildes for autoPlay). |