Requires

Provides

Fx.Move.js

Defines Fx.Move, a class that works with Element.Position.js to transition an element from one location to another.

License:
MIT-style license
Authors:
Aaron Newton
  1. 25
  2. 26
  3. 27
  4. 28
  5. 29
  6. 30
  7. 31
  8. 32
  9. 33
  10. 34
  11. 35
  12. 36
  13. 37
  14. 38
  15. 39
  16. 40
  17. 41
  18. 42
  19. 43
  20. 44
  21. 45
  22. 46
  23. 47
  24. 48
  25. 49
  26. 50
  27. 51
  28. 52
  29. 53
  30. 54
  31. 55
  32. 56
  33. 57
  34. 58
  35. 59
  36. 60
  37. 61
  38. 62
  39. 63
  40. 64
  41. 65
  42. 66
  43. 67
  44. 68
  45. 69
  46. 70
  47. 71
  48. 72
  49. 73
  50. 74
  51. 75
  52. 76
  53. 77
  54. 78
  55. 79
Fx.Move = new Class({ Extends: Fx.Morph, options: { relativeTo: document.body, position: 'center', edge: false, offset: {x: 0, y: 0} }, start: function(destination){ var topLeft = this.element.getStyles('top', 'left'); if (topLeft.top == 'auto' || topLeft.left == 'auto') { var op; if (!Browser.ie){ var parent = this.element.getParent(); op = (parent.getComputedStyle('position') != 'static' ? parent : parent.getOffsetParent()); } var current = this.element.getPosition(op); var margin = this.element.getStyles('margin-top', 'margin-left'); if (topLeft.top == 'auto') this.element.setStyle('top', current.y - margin['margin-top'].toInt()); if (topLeft.left == 'auto') this.element.setStyle('left', current.x - margin['margin-left'].toInt()); } return this.parent(this.element.position(Object.merge(this.options, destination, {returnPos: true}))); } }); Element.Properties.move = { set: function(options){ this.get('move').cancel().setOptions(options); return this; }, get: function(){ var move = this.retrieve('move'); if (!move){ move = new Fx.Move(this, {link: 'cancel'}); this.store('move', move); } return move; } }; Element.implement({ move: function(options){ this.get('move').start(options); return this; } });