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

@adwatch/drag

v1.0.0

Published

Dragndrop module and implementation of keys navigation

Downloads

3

Readme

#Drag

Dragndrop module and implementation of keys navigation

Example

Install

$ npm install --save @adwatch/drag

Usage

import Drag from '@adwatch/drag';
// or
var Drag = require('@adwatch/drag/build');

API

####init()

Initialize Drag

drag.init();

####set(options)

Set options to specimen of Drag. This method reload controller automatically. It means Drag-module will refreshed all properties.

drag.set({
    $elem: '.box',
    $borderElem: '.wrap',
    dragEndTimeout: 100
});

####bind(selectors)

Method binds DOM nodes with Drag mechanics

selectors

Type string

drag.bind('.box, .boxa');

####unbind(selectors)

Method unbind DOM nodes

selectors

Type string

drag.unbind('.box, .boxa');

OPTIONS

####$elem

Initial selector which will be bound with Drag mechanics

Type string

let drag = new Draggable({
        $elem: '.box, .boxa'
    }).init();

####$borderElem

Set borders where will be draggable actions

Type string Default false

drag.set({$borderElem: '.border'});

####dragEndTimeout

Set timer for dragEnd condition

Type number

drag.set({dragEndTimeout: 2000});

####clsDragElem

Set main class for Draggable DOM nodes

Type string Default adw-drag

drag.set({clsDragElem: 'myClass'});

####clsDragStart

Set class for drag-start event

Type string Default adw-drag_start

drag.set({clsDragStart: 'myClass'});

####clsDragMove

Set class for drag-move event

Type string Default adw-drag_move

drag.set({clsDragMove: 'myClass'});

####clsDragEnd

Set class for drag-end event

Type string Default adw-drag_end

drag.set({clsDragEnd: 'myClass'});

####clsDragDest

Set class for drag-on-destination event

Type string Default adw-drag_on-dest

drag.set({clsDragDest: 'myClass'});

####destination.target

Set destination target

Type string Default false

drag.set({
    destination: {
        target: '.destination'
    }
});

####destination.strict

Set strict mode for destination

Type boolean Default false

drag.set({
    destination: {
        strict: true
    }
});

####backAgain

When dragEnd event occurs current draggable node will reset on initial position

Type boolean Default false

drag.set({backAgain: true});

####clone

Set clone node option

Type boolean Default false

drag.set({clone: true});

####cloneKey

Set key or key combination for cloning DOM nodes. NOTE: enable "clone" option is not required.

Type array Default false

drag.set({cloneKey: [17, 18]});

####cloneKey

Set key or key combination for cloning DOM nodes. NOTE: enable "clone" option is not required.

Type array Default false

drag.set({cloneKey: [17, 18]});

####clearGarbage

Clear garbage node after drag-end event

Type boolean Default false

drag.set({clearGarbage: true});

####clearGarbage

Clear garbage node after drag-end event

Type boolean Default false

drag.set({clearGarbage: true});

####imposition

Set barriers for your draggable elements

Type string Default false

drag.set({imposition: '.wall, .another-brick-in-the-wall'});

####navigation

Set this option and drags your element by keyboard

Type object Default false

drag.set({navigation: {
      up: [38],
      right: [39],
      down: [40],
      left: [37],
      step: 10
}});

####callOnTarget(target, elem, callOnTarget, lastPoint)

Callback which occurs when dragEnd event was on destination target

Type function Default false

drag.set({callOnTarget: function(target, elem, callOnTarget, lastPoint){
    console.log(target);
    console.log(elem);
    console.log(callOnTarget);
    console.log(lastPoint);
}});

####callDragEnd(elem, callOnTarget, lastPoint)

Callback which occurs when dragEnd event was occur

Type function Default false

drag.set({callDragEnd: function(elem, callOnTarget, lastPoint){
    console.log(elem);
    console.log(callOnTarget);
    console.log(lastPoint);
}});

License

MIT ©