GithubHelp home page GithubHelp logo

seco / dragdrop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kbjr/dragdrop

0.0 1.0 0.0 140 KB

A JavaScript micro-framework for adding drag-and-drop functionality to elements for advanced UI development

Home Page: http://kbjr.github.io/DragDrop/index.html

License: Other

dragdrop's Introduction

DragDrop

A JavaScript micro-framework for adding drag-and-drop functionality to elements for advanced UI development

Author: James Brumond
Version: 0.2.3-beta

Copyright 2011 James Brumond
Dual licensed under MIT and GPL

Notice

The change to version 0.2.1-beta is NOT backwards compatible. Make sure to look over the samples below.

Features

  • Simple and intuitive interface
  • Option to seperate the event target from the dragged element
  • Bindable dragstart/drag/dragend events
  • Option to define bounding boxes (new in version 0.2.1-beta)
  • Very lightweight (only 1.8kb minified and gzipped)

Samples! :)

// Make myElement drag-and-drop enabled
DragDrop.bind(myElement);

// A more complex version
var draggable = DragDrop.bind(myElement, {
    // The anchor; myElement moves when anotherElement is dragged
    anchor: anotherElement,
    // The draggable element will now stay bound within it's offsetParent
    boundingBox: 'offsetParent',
    // Define a dragstart event
    dragstart: function(evt) {
        // ...
    }
});

// Change the bounding box to some manual positions
draggable.setBoundingBox({
    x: { min: 0, max: 600 },
    y: { min: 0, max: 400 }
});

// Define a new dragend event
draggable.bindEvent('dragend', function(evt) {
    // ...
});

// This is how you would remove a drag event (if one were defined above)
draggable.unbindEvent('drag', theBoundDragEventFunction);

dragdrop's People

Contributors

kbjr avatar tomtheisen avatar

Watchers

 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.