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-interactable-slider

v1.1.8

Published

Touch and responsive slider based on React Native Interactable

Downloads

17

Readme

Demo

https://zniik.github.io/react-interactable-slider/

This was created for the purpose of properly showing product cards for ltr and rtl direction. It has some limitations or doesn't support the following feature:

  • Autoplay
  • Infinite slides
  • Center aligned
  • Image lazy loading (We can use 3rd party for now)
  • Un-equal slides

Supported Feature

Below are the supported feature with their default value.

/**
 * Alignment of the slider
 * @param {'left'|'right'}
 */
cellAlign={'left'}

/**
 * Provide custom React Element for your arrows
 * It will wrap your component to a div with a class of
 * custom-left-arrrow and custom-right-arrow. Also, the
 * custom arrow will receive disabled and navigationType props
 * so you can handle css properly.
 * Make sure navigationType is set to arrows or both and it
 * will automatically show when slides exceeds the container width
 * @param {Element}
 */
customArrows={{ left: <LeftArrow />, right: <RightArrow />}}

/**
 * Toggle drag functionality
 * @param {Boolean}
 */
dragEnabled={true}

/**
 * Reveal debugging borders and snapPoints
 * around with your slider
 * @param {Boolean}
 */
debug={false}

/**
 * Type of navigation for the slider
 * @param {'arrows', 'both', 'dots', 'none'}
 */
navigationType={'none'}

/**
 * Turn each slide of the slider into full width
 * (widthPerSlide configuration is ignored if this property is true)
 * @param {Boolean}
 */
fullWidthPerSlide={false}

/**
 * The margin gaps between the slides
 * (Total in between, this case its value multiply by 2)
 * @param {Number}
 */
marginGapsPerSlide={4}

/**
 * Define the width of each slide
 * (This is ignored when fullWidthPerSlide property is true)
 * @param {Number}
 */
widthPerSlide={200}

How to use the plugin

Build the slider and put your custom content or elements. Please take note that the slides should not have any inline/css style width. Instead, we will define that in our plugin configuration.

Important notes before creating your slider:

  • Add borders to your element to visually see the width when building your initial slides.
import ReactInteractableSlider from 'react-interactable-slider';

const style = {
  height: 300,
  border: '1px solid #ddd'
};

function App() {
  return (
    <ReactInteractableSlider
      cellAlign="left"
      navigationType="dots"
      widthPerSlide={182}
      marginGapsPerSlide={4}
      debug={true}
    >
      <div style={style}>1</div>
      <div style={style}>2</div>
      <div style={style}>3</div>
      <div style={style}>4</div>
      <div style={style}>5</div>
      ...
    </ReactInteractableSlider>
  );
}

Dynamic Slides

import ReactInteractableSlider from 'react-interactable-slider';

const [slides, setSlides] = useState(Array.from(Array(10).keys()));

const style = {
  height: 300,
  border: '1px solid #ddd'
};

function App() {
  return (
    <>
      <button onClick={() => setSlides([...slides, slides.length])}>Add 1 slide</button>
      <button onClick={() => setSlides(slides.slice(0, -1))}>Remove 1 slide</button>
      <ReactInteractableSlider debug={true} navigationType={'both'}>
        {slides.map(v => (
          <div style={style} key={v}>
            {v + 1}
          </div>
        ))}
      </ReactInteractableSlider>
    </>
  );
}