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

simple-dragn

v1.0.5

Published

An easy to use JavaScript drag and drop library.

Downloads

2

Readme

About SimpleDragn

SimpleDragn makes drag 'n drop easy. Simply add classes to the elements that you need to interact with, and you're good to go!


Installation

  1. Install with NPM

    npm install simple-dragn
  2. Or include links to the CDN in your HTML

<link rel="stylesheet" href="https://unpkg.com/[email protected]/stand-alone/core.css">
<script src="https://unpkg.com/[email protected]/stand-alone/dragnDrop.js">

Usage

  1. Add the dragn class to all elements you wish to become draggable. Add a child to these elements with the class of dragn-grab. These will act as the controls to activate and move around its parent, the dragn class element.
<div class="dragn">
   <div class="dragn-grab"></div>
</div>
  1. Add the dragn-den class that you want to use as the containers for the draggable elements to be dropped into.
<div class="dragn-den"></div>

You can also add the dragn elements to start inside of the dragn-den elements.

<div class="dragn-den">
   <div class="dragn">
      <div class="dragn-grab"></div>
   </div>
</div>
  1. Instantiate a new DragnDrop object, and call the initEvents() method when your page is ready. If you add more elements dynamically, you can simply call the initEvents() method again to attach all the events to those new elements.
var dragnDrop = new DragnDrop();
dragnDrop.initEvents();

SimpleDragn is set up to be used as either a CDN, or an NPM package that you can install and bundle with your application.

Here is an example of how to create a basic HTML document that uses the CDN to create draggable elements:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>SimpleDragn Sample App</title>      
        <link rel="stylesheet" href="https://unpkg.com/[email protected]/stand-alone/core.css">
        <style>
            * {
                box-sizing: border-box;
            }            
            html, body, .container {
                height:100%;
                margin: 0;
                padding: 0;
            } 
            .container {
                display: flex;
                flex-direction: column;
            }           
            .row {
                flex: 1;
                display: flex;
                flex-direction: row;
            }
            .dragn {
                height: 100%;
                width: 100%;
                background-color: black;
                color: white;
                border-radius: 5px;
            }
            .dragn-grab {
                height: 20px;
                background-color: #3c91e6;
                border-radius: 5px 5px 0 0 ;
            }
            .dragn-den {
                padding: 20px;
                border: black solid 1px;
                height: 100%;
                flex: 1;
            }
            .dragn-den-hover {
                background-color: #D3D3D3;
            }
        </style>
    </head>
    <body>
        <div id="container" class="container">
            <div class="row">
                <div class="dragn-den">
                    <div class="dragn">
                        <div class="dragn-grab"></div>
                    </div>
                </div>
                <div class="dragn-den">
                    <div class="dragn">
                        <div class="dragn-grab"></div>
                    </div>
                </div>
                <div class="dragn-den"></div>
                <div class="dragn-den"></div>
            </div>  
            <div class="row">
                <div class="dragn-den">
                    <div class="dragn">
                        <div class="dragn-grab"></div>
                    </div>
                </div>
                <div class="dragn-den"></div>
                <div class="dragn-den"></div>
                <div class="dragn-den"></div>
            </div>
        </div>
        <script src="https://unpkg.com/[email protected]/stand-alone/dragnDrop.js"></script>
        <script>
            var dragnDrop = new DragnDrop();
            dragnDrop.initEvents();
        </script>
    </body>    
</html>

License

Distributed under the MIT License.


Contact

LinkedIn - in/anker-peet

Portfolio: ankerpeet.com