Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-touch-drag-slider

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-touch-drag-slider

Touch and drag slider carousel component for React

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
282
decreased by-10.48%
Maintainers
1
Weekly downloads
 
Created
Source

react-touch-drag-slider

Touch and drag slider carousel component for React

  • Touch friendly on mobile
  • Responsive to viewport resizing
  • Supports mouse drag by default
  • Simple API

Install

npm install --save react-touch-drag-slider

Usage

import React from 'react'
import Slider from 'react-touch-drag-slider'

import images from './images'

function App() {

  return (
    <>
        <Slider
          onSlideComplete={(i) => {
            console.log('finished dragging, current slide is', i)
          }}
          onSlideStart={(i) => {
            console.log('started dragging on slide', i)
          }}
          activeIndex={0}
          threshHold={100}
          scale={true}
          transition={0.5}
        >
          {images.map(({ url, title }, index) => (
            <img src={url} key={index} alt={title} />
          ))}
        </Slider>
    </>
  )
}

export default App

Available Props

PropTypeDefaultDescription
onSlideComplete(completedIndex) => completedIndexnullfunction that gets called when finished
onSlideStart(startIndex) => startIndexnullfunction that gets called on start
activeIndexNumber0set to start on this index or use state to update the current index
threshHoldNumber100pixel value that must be dragged before slide snaps to position
scaleBooleantruescale on drag or not
transitionNumber0.3Transition delay in seconds

Examples

With buttons - CodeSandbox

License

MIT © bushblade

Keywords

FAQs

Package last updated on 18 Jan 2021

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