0.0.13 • Published 1 year ago

@es-space/es-drager-react v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

✨ Features

  • 🎯 Drag & drop with constraints
  • 🔄 Rotation support
  • ⚖️ Scale with mouse wheel
  • 🔗 Connection points with bezier curves
  • 📏 Snap to grid & alignment guides
  • 🎨 Tailwind CSS styling
  • 🎮 Rich interaction events

📦 Installation

# npm
npm install @es-space/es-drager-react

# yarn
yarn add @es-space/es-drager-react

# pnpm
pnpm add @es-space/es-drager-react

🚀 Usage

import { Drager } from '@es-space/es-drager-react'

function App() {
  return (
    <Drager
      className="w-32 h-32 bg-blue-500"
      rotatable
      scalable
      onDrag={pos => console.log(pos)}
    >
      Drag me!
    </Drager>
  )
}

📝 Props

PropTypeDefaultDescription
idstringauto-generatedUnique identifier for the drager
classNamestring-CSS class names
styleCSSProperties-Inline styles
rotatablebooleanfalseEnable rotation
scalablebooleanfalseEnable scaling
minScalenumber0.5Minimum scale value
maxScalenumber2Maximum scale value
showGuidesbooleanfalseShow alignment guides
snapToElementsbooleanfalseEnable snapping to other elements
snapThresholdnumber5Snapping threshold in pixels
connectablebooleanfalseEnable connection points
limitObject-Movement constraints
onDragfunction-Drag event handler
onRotatefunction-Rotation event handler
onScalefunction-Scale event handler
onConnectfunction-Connection event handler

🌰 Examples

Basic Dragging

<Drager className="w-32 h-32 bg-blue-500">
  Basic draggable element
</Drager>

With Rotation

<Drager
  className="w-32 h-32 bg-blue-500"
  rotatable
>
  Rotatable element
</Drager>

With Scaling

<Drager
  className="w-32 h-32 bg-blue-500"
  scalable
  minScale={0.5}
  maxScale={2}
>
  Scalable element
</Drager>

With Connections

<Drager
  id="drager1"
  className="w-32 h-32 bg-blue-500"
  connectable
  onConnect={(sourceId, sourceAnchor, targetId, targetAnchor) => {
    console.log('Connected:', { sourceId, sourceAnchor, targetId, targetAnchor })
  }}
>
  Connectable element
</Drager>

🔨 Development

# Install dependencies
bun install

# Start development
bun dev

# Build package
bun build

📄 License

ES Drager is open source software licensed as MIT.

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago