Share Posted June 26, 2019 (edited) 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 June 26, 2019 by ninmorfeo i need to kill all istance not only one Link to comment Share on other sites More sharing options...
Share Posted June 26, 2019 Hi @ninmorfeo, A case in a CodePen would be great and helpful ... See the Pen pXWbwy by mikeK (@mikeK) on CodePen Happy tweening ... Mikel 1 Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 hi thanks for answare but i don t want kill single istance....but all ones Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 no solution ? Link to comment Share on other sites More sharing options...
Share Posted June 26, 2019 I'm not sure I follow, but I think you'd want to push each draggable instance into array when you create it. Then loop through the array and kill() them all when you're done with them. 2 Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 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 More sharing options...
Share Posted June 26, 2019 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. 1 Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 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 More sharing options...
Share Posted June 26, 2019 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(); 1 Link to comment Share on other sites More sharing options...
Share Posted June 26, 2019 So replace this... Draggable.get(".box").kill(); With this... this.kill(); 1 Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 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 More sharing options...
Share Posted June 26, 2019 What language do you speak? If you want to kill something by class, and you're using jQuery, then do this. $(".kill-these-boxes").each(function(index, element) { Draggable.get(element).kill(); }); 2 1 Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2019 italian ...im using traslator Link to comment Share on other sites More sharing options...
Share Posted June 26, 2019 Are you trying to do this?: this.endDrag() 1 Link to comment Share on other sites More sharing options...
Share Posted June 26, 2019 Hi @ninmorfeo, If you can define a condition for your purposes, then it could work that way: See the Pen LKzQeR by mikeK (@mikeK) on CodePen Happy dragging ... Mikel 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now