Git Product home page Git Product logo

drip-drop's Issues

API suggestions

I've just found this project and it looks promising (anything preventing me from having to deal with the native API is promising as hell), but I find the API to be mildly... weird. Looking at your example:

var dd = require("drip-drop")

looks great so far.

dd.drag(myDomNode, {

how about new dd.Draggable(myDomNode, options) instead? Seems a little more obvious to me.

    dragImage: true, // default drag image
    start: function(setData, e) {
        setData('myCustomData', JSON.stringify({a:1, b:"NOT THE BEES"})) // camel case types are allowed!*
    }
})

instead of setData, why not pass a data object to the start callback which you can append new values to? We're in the golden ages of JS right now and can even use Object.assign() ๐Ÿ˜„

dd.drop(myDropzone, {

same as above - new dd.Dropzone(myDomNode, options) maybe?

    drop: function(data, e) {
        myDropzone.innerHTML = data.myCustomData
    }
})

Or by using one of the available EventEmitter libraries and provide just the following:

let dropZone = new DripDrop(myDomNode, options);

dropZone.on('drag', (data, event) => Object.assign(data, {
  myCustomData: JSON.stringify({a:1, b:"BUT I LOVE BEES"})
}));

dropZone.on('idle', stoppedDragging);
dropZone.on('drop', droppedSomething);
// ...

...and so on. I know dragging and dropping can be used for different things, but usually, if you provide drag functionality, you want something to happen if things are dropped again so combining both in the same instance would make sense.
What do you think?

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.