Socket
Socket
Sign inDemoInstall

react-scrubber

Package Overview
Dependencies
71
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-scrubber

React scrubber component with touch controls, styling, and lots event handlers


Version published
Weekly downloads
1.1K
decreased by-16.09%
Maintainers
1
Install size
3.63 MB
Created
Weekly downloads
 

Readme

Source

react-scrubber

A simple React scrubber component with touch controls, styling, and event handlers. Integrated TypeScript support. See more information and a live demo at https://nick-michael.github.io/react-scrubber/

The code for the above demo can be found inside the repository in the '/demo' folder.

Dependencies

React is listed as a peer dependency. React should be added as a dependency to your project. The component provides its styling with a CSS stylesheet (scrubber.css) file, so you'll need to import it and have webpack set up to handle css imports. The typical combination of style-loader and css-loader works great!

Usage

import  React, { Component } from  'react';
import { Scrubber, ScrubberProps } from 'react-scrubber';
// Note: ScrubberProps is a TypeScript interface and is not used for JS projects

import 'react-scrubber/lib/scrubber.css'

class App extends Component {
  state = {
    value: 50,
    state: 'None',
  }

  handleScrubStart  = (value:  number) => {
    this.setState({ value, state:  'Scrub Start' });
  }

  handleScrubEnd  = (value:  number) => {
    this.setState({ value, state:  'Scrub End' });
  }

  handleScrubChange  = (value:  number) => {
    this.setState({ value, state:  'Scrub Change' });
  }

  render() {
    return (
      <div  className="scrubber-container"  style={{ height:  '20px' }}>
        <Scrubber
          min={0}
          max={100}
          value={this.state.value}
          onScrubStart={this.handleScrubStart}
          onScrubEnd={this.handleScrubEnd}
          onScrubChange={this.handleScrubChange}
        />
      </div>
    );
  }
}

Props

NameTypeRequiredDescription
classNamestringNoSets the class name for the scrubber div
valuenumberYesSet current value of slider
minnumberYesThe minimum value of the slider
maxnumberYesThe maximum value of the slider
bufferPositionnumberNoSome number higher than the value, used to render a 'buffer' indicator
verticalbooleanNoThe scrubber will render vertically
onScrubStartfunctionNoCalled on mouse down or touch down
onScrubEndfunctionNoCalled on mouse up or touch up while scrubbing
onScrubChangefunctionNoCalled on mouse move while scrubbing
onMouseMovefunctionNoCalled with the scrub value of the cursor position when the mouse moves inside the scrubber element
onMouseOverfunctionNoCalled with the scrub value of the cursor position when the mouse enters scrubber element
onMouseLeavefunctionNoCalled with the scrub value of the cursor position when the mouse leaves scrubber element
markersArray<number | { start: number, end?: number, className?: string }>NoAdds yellow indicators to the scrubber bar
tooltip{
 enabledOnHover?: boolean;
 enabledOnScrub?: boolean;
 className?: string;
 formatString?: (value: number) => string;
}
NoRenders a tooltip while hovering/scrubbing
custom propsanyNoAny other props will be applied to the outermost 'scrubber' div

Keywords

FAQs

Last updated on 13 Jul 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc