npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

draggable_dialog

v1.0.3

Published

A Javascript library that turn draggable elements and can be used in react, vue and angular

Downloads

4

Readme

Create A Draggable, Resizable, and Custom Dialog

Terminal in browser

This is a library that use Vanilla Javascript to create draggable dialogs. He automates the process of create events that listen to the touches and clicks and moves.

So, you don't need to worry about create javascript code, to turn draggable your elements, you will only create the html and styles of the dialog, and the lib will turn it draggable to desktop and phones users.

See a demo page, and as the source code is simple.

Why?

The dialog box in sites are very common, they have different utilities. But, I don't know something that helps developers to automate the process of creating Draggable dialogs. I only found a snippet of codes that are either poorly documented or difficult to custom, or with another mistake.

So to help me and the others, I decided to write a lib that turns containers draggable, she should be custom, easy to use, and well documented.

Examples

To turn a dialog draggable, you need only type this:

new Draggable({
  "dialogId"                   : "elementId",
  "elementThatCaptureTheClick" : "elementId"
})

As you see, you have to pass to Draggable an object with the id of the element that will be draggable and the id of the element that will listen to touches and clicks to drag the dialog. Normally, this is the top bar of the dialog, but can be whatever element that you want, or can be the entire dialog, so you can drag touching in any part of the dialog.

To see more methods that this object can have, see the documentation section.

Installation

The library can be used in the browser or in NodeJs environment to be used in React or other libraries.

Installation in browser

To use in the browser, you can import this library in a tag script:

<script src="https://cdn.jsdelivr.net/gh/raulpy271/DraggableDialog@master/dist/Draggable.js"></script>

Installation in NodeJs (ReactJs or others libraries)

You can use the npm to install this library with this command:

$ npm install draggable_dialog --production

I used this library with reactJs, but you can use it with whatever library/framework that you want. It's simple, you only need to install it with npm and execute the Draggable class, but you have to pay attention to execute it when the component is rendered.

See an example in react:

import {useEffect} from 'react'
import Draggable from 'draggable_dialog'
import MyComponent from './MyComponent.js'


const MyComponentDraggable = () => {
  useEffect( () => 
    new Draggable({
      "dialogId" : "MyComponentId",
      "elementThatCaptureTheClick" : "MyComponentId"
    })
  )
  return <MyComponent/>
}

I use useEffect to execute the library after the component is rendered. Feels free to add examples with other libraries.

documentation

To use all features you should know all parameters passed to the Draggable class. The parameters is passed via an object. This object can have these methods:

Object Key | Importance | Action ---------- | ---------- | ------ dialogId | required | This is the id of the entire dialog elementThatCaptureTheClick | required | This is the id of the element that will listen for drags centerElement | optional | A boolean value. if it's true then the library will centralize the element, or If it's omitted or is false, the library doesn't will hideButtonId | optional | The id of the close button. If used, the library will add an event in this button to close the dialog when the button has clicked showButtonId | optional | The id of the button that shows the dialog. If used, the library will add an event in this button to show the dialog only when clicked