Code Monkey home page Code Monkey logo

Comments (12)

mlshvdv avatar mlshvdv commented on August 18, 2024

👍

from contenttools.

anthonyjb avatar anthonyjb commented on August 18, 2024

I agree these would be useful additions, happy to add. So the new events will be:

  • drag
  • drop (only executed if content is successfully dropped on another element that accepts the drop action)

Does that offer everything needed?

UPDATE: The drag event would receive the element dragged as a value. The drop event would receive the element dropped as well as the element being dropped onto and the placement.

from contenttools.

bfintal avatar bfintal commented on August 18, 2024

How about when the drop is performed in the same place?

from contenttools.

anthonyjb avatar anthonyjb commented on August 18, 2024

If it's dropped on the the element above, below, left, right in such a way as to stay in the same position on the page the drop event would still trigger, but it would be easy to check if it had moved by reviewing the element (if any) before it.

from contenttools.

anthonyjb avatar anthonyjb commented on August 18, 2024

Just updating the documentation for the additional events now - but feel free to use:

ContentEdit.Root.get().bind('drag', function (element) { ... });
ContentEdit.Root.get().bind('drop', function (element, target, placement) { ... });

from contenttools.

mlshvdv avatar mlshvdv commented on August 18, 2024

You're really fast! Thank you!

from contenttools.

bfintal avatar bfintal commented on August 18, 2024

Thank you!

from contenttools.

bfintal avatar bfintal commented on August 18, 2024

Oh, and the docs in the site are already updated too 👍

from contenttools.

bfintal avatar bfintal commented on August 18, 2024

Okay so I tried the new events. The drop event isn't getting triggered when the drag is cancelled - e.g. you drag it to the same place. I think it should still get triggered, since if you do something during the drag event, you can't perform an undo method on the drop event since it isn't called.

Maybe you can add a cancelled boolean property to the object?

I have worked around this, to capture the cancelled drag event by adding a mouseover handler to the dom element after the drag event, then removing it right after.

from contenttools.

anthonyjb avatar anthonyjb commented on August 18, 2024

Yeah drop only trigger if the element was dropped on another valid element, I could modify the call so that the target and placement values for the event are null if there is no valid target?

from contenttools.

anthonyjb avatar anthonyjb commented on August 18, 2024

@bfintal OK you should now get an event valid or invalid - hope that helps and removes the need for the workaround :)

from contenttools.

bfintal avatar bfintal commented on August 18, 2024

Super thanks yet again! 👍

from contenttools.

Related Issues (20)

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.