0.2.1 • Published 4 years ago

@leveluptuts/drop-in v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@leveluptuts/drop-in

Drop In

Jaws Aaron Homoki

NPM

Demo

https://levelup-drop-in.netlify.com/

Install

yarn add @leveluptuts/drop-in

Usage

The Syntax

import { DropIn, DragItem } from '@leveluptuts/drop-in';

function Component() {
  return (
    <DropIn data={data}>
      {activeColors.map(({ background, height }) => (
        <DragItem key={background}>
          <Square background={background} height={height} />
        </DragItem>
      ))}
    </DropIn>
  );
}

More options

import { DropIn, DragItem } from '@leveluptuts/drop-in';

function Component() {
  return (
    <DropIn data={data} whileHover={{ scale: 1.02 }} whileTap={{ scale: 1.04 }}>
      {activeColors.map(({ background, height }) => (
        <DragItem key={background}>
          <Square background={background} height={height} />
        </DragItem>
      ))}
    </DropIn>
  );
}

API

DropIn

The parent of an array of components

PropTypeDefaultDescription
childrenArrayOfComponentsAn array of React Components
dataArrayOfDataThe data that powers the children
onDropfunc(data) => dataOPTIONAL _ function that runs on drop, sends new data
whileTapFramer Property{ scale: 1.12 }OPTIONAL _ object that sets the animation state
whileHoverFramer Property{ scale: 1.03 }OPTIONAL _ object that sets the animation state

DragItem

The item to be moved

PropTypeDefaultDescription
keystringA unique key
childrenComponent or ElementThe thing inside the thing you're moving
elementdom element for drag item'div'A string of the dom element being dragged

FAQ

Contributing

yarn yarn start

(in another tab) to run example

cd example yarn yarn start

Prior Art and Inspirations

Lots of this code has been adopted from https://codesandbox.io/s/framer-motion-drag-to-reorder-r4qme

License

MIT © leveluptuts

0.2.1

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago