Jump to content
Search Community

How to Kill all drag istance?

ninmorfeo test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

 

it seems that it doesn't work, i wish to kill all drag instance ...

 

   Draggable.create(".drag_item", {
            bounds: $('.drag_zone'),
            edgeResistance: 0.9,
            type: "x,y",
            throwProps: true,
            throwResistance: 2000,
            maxDuration: 0.2,

 onRelease: function () {
                if (this.hitTest('#dropzone')) {

               

                        
                        Draggable.get(".drag_item").kill();
               

 

                } else {

                    tmax.to(this.target, 0.1, {
                        rotationX: 20,
                        scaleX: 0.6,
                        scaleY: 0.6,
                        boxShadow: "-2px 2px 5px 0px rgba(0,0,0,0.75)"
                    });

                }

            }
});

See the Pen MMEeyy?editors=1111 by Ninmorfeo (@Ninmorfeo) on CodePen

Edited by ninmorfeo
i need to kill all istance not only one
Link to comment
Share on other sites

8 minutes ago, PointC said:

Non sono sicuro di seguirlo, ma penso che vorresti spingere ogni istanza trascinabile in array quando lo crei. Quindi fai un ciclo attraverso l'array e uccidi () tutti quando hai finito con loro.

 

I thought there was a more immediate method ...

I have a deck of 40 cards, the user chooses 10 cards using drag and drop, after which I have to make sure that the dragging function is no longer attached to the remaining cards.

 

So to solve I have to create an array with 40 cards, eliminate the selected cards from the array and only end up cycling on the cards left in the array and use the kill command on each instance?

 

a bit hateful ....

If there is no other way I think that in the future a solution should be implemented in the draggable class, because all the other libraries I used have a method to eliminate dragging, in some libraries it was enough for me to simply delete the class from the objects, for example if a div had the class "drag", it was enough that I eliminated such class through jquery

Link to comment
Share on other sites

40 minutes ago, ninmorfeo said:

 

I thought there was a more immediate method ...

I have a deck of 40 cards, the user chooses 10 cards using drag and drop, after which I have to make sure that the dragging function is no longer attached to the remaining cards.

 

It's very easy to do, but you need to show us with a demo how you are getting those cards to kill. 

 

Deleting a class from an element is a horrible solution. That can lead to poor performance and memory leaks.

  • Like 1
Link to comment
Share on other sites

6 minutes ago, OSUblake said:

 

It's very easy to do, but you need to show us with a demo how you are getting those cards to kill. 

 

Deleting a class from an element is a horrible solution. That can lead to poor performance and memory leaks.

 

the demo is present in the first post above.

Obviously it's not exactly the project I'm doing, but if I can figure out how to edit the demo at the top I will be able to bring it back to my project as well.

 

As you can see there are a series of squares on which the dragging is attached, it would be enough for you to show me how to eliminate the draggin g from all objects after you have placed a square in the dropping area.

 

Exactly as it is reported in the codepen js code that I posted, instead of the Draggable.get (". Box"). Kill () line; instead there should be the function that allows me to kill all the drag

Link to comment
Share on other sites

Just now, ninmorfeo said:

Exactly as it is reported in the codepen js code that I posted, instead of the Draggable.get (". Box"). Kill () line; instead there should be the function that allows me to kill all the drag

 

You should use actual elements instead of selectors. The box class represents 12 different elements.

 

If you want to kill something in your hit test, simply kill it.

 

this.kill();

 

  • Like 1
Link to comment
Share on other sites

5 minutes ago, OSUblake said:

So replace this...

 


Draggable.get(".box").kill();

 

With this...


this.kill();

 


I feel sad ... I can't explain myself ... I wrote it in every answer.

Maybe i hope is not the problem with my English, I don't write well ... I don't have to kill the drag of the released object, but that of everyone else: (((((

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...