Giter Club home page Giter Club logo

jh3y-draggable's Introduction

This repository is a mirror of the component module jh3y/draggable. It has been modified to work with NPM+Browserify. You can install it using the command npm install npmcomponent/jh3y-draggable. Please do not open issues or send pull requests against this repo. If you have issues with this repo, report it to npmcomponent.

draggable

Make an element draggable with configurable behaviours. Compatible with component package manager.

demo

A simple demo of making a draggable div can be seen here.

##usage Use with or without component package manager. Examples of all behaviours can be seen in the demo or in the example page. ###use with component package manager ####installation Install with component(1):

$ component install jh3y/draggable

###use simply create an element and then make it a draggable

var draggable = require('draggable');//ONLY REQUIRED IF USING COMPONENT PACKAGE MANAGER
var element = document.querySelector('.myDraggable');
element.style.height = '50px';
element.style.width = '50px';
element.style.background = 'red';
var myDrag = new draggable(element);

an example of passing in options for pens:

var myPennedDrag = new draggable(element, {
	pens: document.querySelector('.pen')
});

###use without component package manager simply include the standalone version of draggable and create a new draggable from an element

var element = document.querySelector('.myDraggable');
element.style.height = '50px';
element.style.width = '50px';
element.style.background = 'red';
var myDrag = new draggable(element);

an example of passing in options for pens:

var myPennedDrag = new draggable(element, {
	pens: document.querySelector('.pen')
});

api

draggable is really simple to use and the following methods and options are available ###options

####pens: NodeList/array of elements define elements that a draggable will snap into. ####roam: true/false [default: true] defines whether a draggable can be dragged out of pens or whether it must always be contained within one of its defined pens. ####contained: true/false [default: false] defines whether a draggable can be dragged outside of its parent or not. ####vertical: true/false [default: true] defines whether a draggable can be dragged vertically. ####horizontal: true/false [default: true] defines whether a draggable can be dragged horizontally. ####ghosting: true/false [default: false] define whether draggable has ghosting effect (see demo).

###methods There are also some methods you can use on your draggable: ####setPens(NodeList - array of elements) set pen elements for draggable to snap to. ####setContained(bool) set whether a draggable is contained. ####setRoam(bool) set whether a draggable can roam outside of pens. ####setVertical(bool) set whether a draggable can be dragged vertically. ####setHorizontal(bool) set whether a draggable can be dragged horizontally. ####setGhosting(bool) set whether a draggable has the ghosting effect.

License

MIT

jh3y-draggable's People

Contributors

jh3y avatar airportyh avatar

Watchers

James Cloos avatar npm <3 component avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.