3.10.6 • Published 6 months ago

@dflex/draggable v3.10.6

Weekly downloads
97
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install @dflex/draggable

API

DFlex Draggable depends on three principles to achieve DOM interactivity:

  • Register element in the store.
  • Start dragging when mouse is down.
  • End dragging to release element when mouse is up.
import { store, Draggable } from "@dflex/draggable";

Register element

Each element should be registered in draggable store in order to be dragged later.

store.register(id: string);

Create dragging instance

The dragging instance should be created when onmousedown is fired. So you initialized the element before start dragging.

const dflexDraggable = new Draggable(id, clickCoordinates);
  • id: string registered element-id in the store.
  • coordinate: AxesPoint is an object with {x: number, y: number} contains the coordinates of the

Start dragging

dflexDraggable.dragAt(x, y);
  • x: number is event.clientX, the horizontal click coordinate.
  • y: number is event.clientY, the vertical click coordinate.

End dragging

dflexDraggable.endDragging();

Cleanup element

It's necessary to cleanup the element from store when the element won't be used or will be removed/unmounted from the DOM to prevent memory leaks.

store.unregister(id);
  • id: string registered element-id.

Documentation 📖

For documentation, more information about DFlex and a live demo, be sure to visit the DFlex website https://www.dflex.dev/

License 🤝

DFlex is MIT License.

3.9.9

7 months ago

3.9.8

7 months ago

3.9.3

10 months ago

3.9.10

7 months ago

3.9.7

7 months ago

3.9.6

7 months ago

3.9.5

8 months ago

3.9.4

10 months ago

3.10.1

6 months ago

3.10.0

7 months ago

3.10.3

6 months ago

3.10.2

6 months ago

3.10.5

6 months ago

3.10.4

6 months ago

3.10.6

6 months ago

3.9.2

10 months ago

3.9.1

11 months ago

3.9.0

11 months ago

3.8.4

1 year ago

3.8.3

1 year ago

3.8.2

1 year ago

3.8.1

1 year ago

3.8.0

1 year ago

3.7.1

1 year ago

3.7.0

2 years ago

3.5.4

2 years ago

3.6.2

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.5.3

2 years ago

3.5.2

2 years ago

3.5.1

2 years ago

3.5.0

2 years ago

3.4.1

2 years ago

3.4.0

2 years ago

3.3.1

2 years ago

3.3.2

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.15.0

3 years ago

2.14.0

3 years ago

2.13.0

3 years ago

2.12.0

3 years ago

2.11.0

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.1

3 years ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.0

3 years ago

2.2.0

3 years ago

2.2.2

3 years ago

2.1.0

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

4 years ago

0.2.0

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