fresheneesz / drip-drop Goto Github PK
View Code? Open in Web Editor NEWA simple generalized drag-and-drop module that abstracts away most of the drag-and-drop APIs weirdness and surprises.
License: MIT License
A simple generalized drag-and-drop module that abstracts away most of the drag-and-drop APIs weirdness and surprises.
License: MIT License
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?
Hi. Nice little package.
I wanted to inspect the data inside the 'enter' 'leave' callbacks so I can perform some basic logic. How can this be done?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.