Comments (9)
I'll see what I can up with this weekend 👍
from drip-drop.
I'll probably inherit EventEmitter using proto
to minimize changes. Changing to this API shouldn't be hard, but I also want to preserve (and deprecate) the previous API for backwards compatibility.
from drip-drop.
"new dd.Draggable(myDomNode, options)
"
This sounds more like a class to me. I'd expect something like that to return an object instance that has methods and represents the draggable thing. The return value of dd.drag
doesn't represent any draggable thing and doesn't have methods - its just a clean up function. So I don't think that is the right semantics.
"why not pass a data object to the start callback which you can append new values to? "
I suppose that could be done.
"using one of the available EventEmitter libraries"
I like the last API you suggested. I have a nagging feeling that some of that might be a bit hard to do given the absurd hoops this has to jump through to satisfy the native API's requirements. But I can't think of a good reason at the moment why it couldn't be done. I would be open to accepting a pull request for an API like that, tho I'd want to sign off on a more full spec first.
from drip-drop.
Hey @fresheneesz, I rewrote the library to ES6 and moved the event callbacks to use an EventEmitter
. Because I didn't have the time to update building and tests yet, I didn't create a PR but a gist instead: https://gist.github.com/Radiergummi/aba408acd53573f570a8e44d914b210d
There might be serious mistakes, it might not be working at all, but that's what I imagine the API to be, so maybe have a look at it and tell me what you think 😄
from drip-drop.
Hey @Radiergummi , thanks for the work. Its really hard for me to see what you changed since this is a new repo rather than a modification of a previous file. But it looks like the API you're proposing is something like:
var draghandle = DripDrop.drag(domNode, options)
var dropzone = DripDrop.drop(domNode, options)
draghandle.on("start", function(){...})
dropzone.on("enter", function(){...})
dropzone.on("in", function(){...})
dropzone.on("leave", function(){...})
dropzone.on("out", function(){...})
dropzone.on("drop", function(){...})
from drip-drop.
Oops, sorry posted early.
This code seems to leave out a couple events the current version has: drag move, drag end, and drop move. Let me take a stab at doing this this weekend, with your code as a guide.
from drip-drop.
Hey,
Yep, this has become pretty different to the original... Since I wanted to make DripDrop instances that inherit from EventEmitter, I decided to rewrite the files as ES6 classes, that changed pretty much.
On first sight! Basically, everything works mostly as it used to, you can also still pass event callbacks to the constructor as they are automatically attached.
But due to the EventEmitter prototype, you can use instance.on(eventName)
.
Some things are still missing but I didn't have time to finish yet, such as the missing events. I wanted to know what you think anyway 😉
from drip-drop.
...and instance.off
to remove listeners or instance.emit
to manually trigger them
from drip-drop.
Just committed the changes. Should be all good to go! Thanks!
from drip-drop.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drip-drop.