0.2.0 • Published 6 years ago

@pinecodes/draggable v0.2.0

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

Draggable

A super simple drag utility helper.

Usage:

import React, { useState } from 'react';
import draggable from '@pinecodes/draggable';

function MyComponent() {
  const [ left, setLeft ] = useState(50);
  const [ top, setTop ] = useState(50);
  function handleDrag(dx, dy) {
    if (dx !== 0) setLeft(left + dx);
    if (dy !== 0) setTop(top + dy);
  }
  return (
    <div
      style={{ position: 'absolute', left, top }}
      {...draggable(handleDrag)}
    >
      <h1>This content is draggable!</h1>
    </div>
  );
}
0.2.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago