Coder Social home page Coder Social logo

Dragging by using a handle. about interact.js HOT 7 CLOSED

matula avatar matula commented on May 14, 2024 1
Dragging by using a handle.

from interact.js.

Comments (7)

taye avatar taye commented on May 14, 2024 1

I've implemented the allowFrom setting.

     * A drag/resize/gesture is started only If the target of the
     * `mousedown`, `pointerdown` or `touchstart` event or any of it's
     * parents match the given CSS selector or Element.

https://raw.githubusercontent.com/taye/interact.js/master/interact.js

from interact.js.

dpekkle avatar dpekkle commented on May 14, 2024 1

Here's an implementation based on someone elses jsfiddle.

http://jsfiddle.net/dw3xdhch/43/

You can only drag/drop using the handle provided due to
line 2: allowFrom('.handle')

from interact.js.

taye avatar taye commented on May 14, 2024

There's no setting for this so you would have to change the target yourself in your event listeners.

I could implement something like an allowFrom options which would be sort of the reverse of ignoreFrom to only start actions from the matching element or it's children.

from interact.js.

DimitarChristoff avatar DimitarChristoff commented on May 14, 2024

prolly a non-issue but:

https://github.com/taye/interact.js/blob/master/interact.js#L4134

shouldn't this be this._element.querySelector to restrict drag handles to child nodes only? there is no need to take other matching elements into consideration

from interact.js.

taye avatar taye commented on May 14, 2024

You're right, it should only focus on the child nodes. However, the line that you mentioned is only there to test that the given string is a valid CS selector. I've implemented the behaviour in d67646e for both allowFrom and ignoreFrom.

Thanks for mentioning this!

from interact.js.

kevzlou7979 avatar kevzlou7979 commented on May 14, 2024

Can you give a sample code snippet about the implementation? Thanks great framework

from interact.js.

tylercubell avatar tylercubell commented on May 14, 2024

When there are two or more handles in a parent element and you need to know which one is being dragged, see https://jsfiddle.net/Lzzrfybg/.

from interact.js.

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.