Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /**
  2. * Checks if a rectangle belongs in any of the existing groups
  3. */
  4. function removesFromGroup(group, tempRect) {
  5.  
  6. /**
  7. * I created a bin group and I send the rectangle to this group by using group.moveTo(bin)
  8. */
  9. var bin = new Kinetic.Group({
  10. name:'bin',
  11. x : -480,
  12. y : -50
  13. });
  14.  
  15. for (var j = 0; j < group.getChildren().length; j++) {
  16. // var groupCube_x = (groups[i].getChildren()[j]).getAbsolutePosition().x;
  17.  
  18. if (group.getChildren()[j] == tempRect) {
  19. tempRect.moveTo(bin);
  20.  
  21.  
  22. // alert("Move to bin");
  23. //tempRect.remove();
  24. //tempRect.getParent().remove(bin);
  25.  
  26. //bin.destroy();
  27.  
  28.  
  29. layer.draw();
  30. }
  31. }
  32. return false;
  33. }
  34.  
  35. /**
  36. * Checks if a rectangle belongs in any of the existing groups and
  37. * destroys it if so.
  38. */
  39. function removesFromGroup(group, tempRect) {
  40.  
  41. group.getChildren().forEach(function(child){
  42.  
  43. if (child == tempRect) {
  44. tempRect.destroy();
  45. layer.draw();
  46. }
  47. });
  48.  
  49. return false;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement