Git Product home page Git Product logo

Comments (3)

marcospont avatar marcospont commented on June 10, 2024

Hello @AlanBlanchet

Can u elaborate your question better?

from agnostic-draggable.

AlanBlanchet avatar AlanBlanchet commented on June 10, 2024

Hello @marcospont

Sure I'll elaborate the question.

In the docs it says how to create a draggable event with the object :

new Draggable(document.body, {
	axis: 'x'
});

But if I want to remove the event, how do I do it ?

With vanilla js you would do :

const f = (e) => console.log(e)
document.body.addEventListenener("drag", f)
// Do stuff
// .....
// .....
document.body.removeEventListener("drag", f)

from agnostic-draggable.

marcospont avatar marcospont commented on June 10, 2024

@AlanBlanchet

The element passed to the Draggable constructor should be the actual element to be dragged.
I don't think it makes sense to drag the document's body :)

About attaching and detaching of events, the destroy() method of the Draggable class is supposed to remove all event listeners. By the way, all event listeners used to allow elements to be draggable are attached to the document, not to the draggable elements.

from agnostic-draggable.

Related Issues (15)

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.