0.0.13 • Published 11 months ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months 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

11 months ago

0.0.12

11 months ago

0.0.11

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago