Git Product home page Git Product logo

Comments (9)

Radiergummi avatar Radiergummi commented on September 5, 2024 1

I'll see what I can up with this weekend 👍

from drip-drop.

fresheneesz avatar fresheneesz commented on September 5, 2024 1

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.

fresheneesz avatar fresheneesz commented on September 5, 2024

"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.

Radiergummi avatar Radiergummi commented on September 5, 2024

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.

fresheneesz avatar fresheneesz commented on September 5, 2024

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.

fresheneesz avatar fresheneesz commented on September 5, 2024

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.

Radiergummi avatar Radiergummi commented on September 5, 2024

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.

Radiergummi avatar Radiergummi commented on September 5, 2024

...and instance.off to remove listeners or instance.emit to manually trigger them

from drip-drop.

fresheneesz avatar fresheneesz commented on September 5, 2024

Just committed the changes. Should be all good to go! Thanks!

from drip-drop.

Related Issues (2)

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.