dragAnimDemo-mootools.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. unavoidable separate file for jquery specific parts of the dragAnimDemo.
  3. */
  4. ;(function() {
  5. jsPlumbDemo.initClearButton = function() {
  6. $("clear").removeEvent("click", jsPlumb.detachEverything);
  7. $("clear").addEvent("click", jsPlumb.detachEverything );
  8. };
  9. jsPlumbDemo.initAddButton = function() {
  10. $("add").removeEvent("click", jsPlumbDemo.addDisc);
  11. $("add").addEvent("click", jsPlumbDemo.addDisc);
  12. };
  13. jsPlumbDemo.initHover = function(elId) {
  14. $(elId).addEvents({
  15. 'mouseenter' : function() { $(this).addClass("bigdot-hover"); },
  16. 'mouseleave' : function() { $(this).removeClass("bigdot-hover"); }
  17. });
  18. };
  19. jsPlumbDemo.initAnimation = function(elId) {
  20. $(elId).addEvent('click', function(e, ui) {
  21. if ($(this).hasClass("jsPlumb_dragged")) {
  22. $(this).removeClass("jsPlumb_dragged");
  23. return;
  24. }
  25. var o = $(this).getPosition();
  26. var s = $(this).getSize();
  27. var w = s.x, h = s.y;
  28. var c = [o.x + (w/2) - e.page.x, o.y + (h/2) - e.page.y];
  29. var oo = [c[0] / w, c[1] / h];
  30. var DIST = 450;
  31. var dl = Math.abs(oo[0] * DIST);
  32. var dt = Math.abs(oo[1] * DIST);
  33. if (c[0] > 0) dl = dl * -1;
  34. if (c[1] > 0) dt = dt * -1;
  35. l = o.x + dl;
  36. t = o.y + dt;
  37. jsPlumb.animate($(this), {'left':'' + l, 'top':'' + t }, {duration:900});
  38. });
  39. };
  40. })();