Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dflex/draggable

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dflex/draggable

Draggable only package for all JavaScript frameworks

  • 3.10.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-92.59%
Maintainers
1
Weekly downloads
 
Created
Source

DFlex is a Javascript library for modern Drag and Drop apps

DFlex Draggable

Dflex build status number of opened pull requests DFlex last released version number of opened issues Dflex welcomes pull request Follow DFlex on twitter

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.

Keywords

FAQs

Package last updated on 04 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc