1.0.3 • Published 4 years ago

@atayahmet/react-slidify v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

npm version Build Status

React Slidify

React Slidify

React Slidify is a component that transmits position coordinates with callbacks at each step of an object that you can advance by dragging within a field. The component can be use as volume control, music player timeline etc.

Installation

Use the package manager yarn or npm to install react-slidify.

npm i @atayahmet/react-slidify --save
yarn add @atayahmet/react-slidify

Usage

import Slidify from '@atayahmet/react-slidify';

<Slidify
  width="250px"
  height="250px"
  points={[
    {
      x={10}
      y={300}
      width={20}
      height={20}
    }
  ]}
  axis="xy"
  onSlide={callback}
/> 

Props

ISlidifyOptions

nametypedefaultdescription
widthstring100%Width of the field.
heightstring100%Height of the field.
pointsIPoint[][]
multiplebooleanfalseMultiple points.
movablebooleantrueThe points can move or vice versa.
axisstringxyAvailable axes.
defaultBackgroundColorOfPointstringredDefault background color of point.
onStartonStartHandlerArgs-First move event.
onStoponStopHandlerArgs-Last move event.
onSlideonSlideHandlerArgs-Active slide event.
onReachonReachHandlerArgs-Reach point event.

IPoint

nametypedefaultdescription
xnumber-Left position px value.
ynumber-Top position px value.
widthnumberinnerWidthWidth of the point in px.
heightnumberinnerHeightHeight of the point in px.
classNamestring (optional)-Custom class name.
styleReact.CSSProperties (optional)-Css properties.
childrenJSX ElementnullPass JSX element to points.

IEventPoint

nametypedescription
xnumberLeft position px value.
ynumberTop position px value.
widthnumberWidth of the point in px.
heightnumberHeight of the point in px.
axisstringCurrent axis.
percentIPercentX and Y position as percent unit

IPercent

nametypedescription
xnumberLeft position percent value.
ynumberTop position percent value.

Events

nameargumentsdescription
onStartonStartHandlerArgsFirst move event.
onStoponStopHandlerArgsLast move event.
onSlideonSlideHandlerArgsActive slide event.
onReachonReachHandlerArgsReach point event.

Types

onStartHandlerArgs

(point: IEventPoint, index: number) => any

onStopHandlerArgs

(point: IEventPoint, index: number) => any

onSlideHandlerArgs

(point: IEventPoint, index: number) => any

onReachHandlerArgs

(point: IEventPoint, at: ReachPoint, index: number) => any

ReachPoint

'start-point' | 'end-point'

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT