Queue2.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-fx-Queue'>/**
  19. </span> * @class Ext.fx.Queue
  20. * Animation Queue mixin to handle chaining and queueing by target.
  21. * @private
  22. */
  23. Ext.define('Ext.fx.Queue', {
  24. requires: ['Ext.util.HashMap'],
  25. constructor: function() {
  26. this.targets = new Ext.util.HashMap();
  27. this.fxQueue = {};
  28. },
  29. // @private
  30. getFxDefaults: function(targetId) {
  31. var target = this.targets.get(targetId);
  32. if (target) {
  33. return target.fxDefaults;
  34. }
  35. return {};
  36. },
  37. // @private
  38. setFxDefaults: function(targetId, obj) {
  39. var target = this.targets.get(targetId);
  40. if (target) {
  41. target.fxDefaults = Ext.apply(target.fxDefaults || {}, obj);
  42. }
  43. },
  44. // @private
  45. stopAnimation: function(targetId) {
  46. var me = this,
  47. queue = me.getFxQueue(targetId),
  48. ln = queue.length;
  49. while (ln) {
  50. queue[ln - 1].end();
  51. ln--;
  52. }
  53. },
  54. <span id='Ext-fx-Queue-method-getActiveAnimation'> /**
  55. </span> * @private
  56. * Returns current animation object if the element has any effects actively running or queued, else returns false.
  57. */
  58. getActiveAnimation: function(targetId) {
  59. var queue = this.getFxQueue(targetId);
  60. return (queue &amp;&amp; !!queue.length) ? queue[0] : false;
  61. },
  62. // @private
  63. hasFxBlock: function(targetId) {
  64. var queue = this.getFxQueue(targetId);
  65. return queue &amp;&amp; queue[0] &amp;&amp; queue[0].block;
  66. },
  67. // @private get fx queue for passed target, create if needed.
  68. getFxQueue: function(targetId) {
  69. if (!targetId) {
  70. return false;
  71. }
  72. var me = this,
  73. queue = me.fxQueue[targetId],
  74. target = me.targets.get(targetId);
  75. if (!target) {
  76. return false;
  77. }
  78. if (!queue) {
  79. me.fxQueue[targetId] = [];
  80. // GarbageCollector will need to clean up Elements since they aren't currently observable
  81. if (target.type != 'element') {
  82. target.target.on('destroy', function() {
  83. me.fxQueue[targetId] = [];
  84. });
  85. }
  86. }
  87. return me.fxQueue[targetId];
  88. },
  89. // @private
  90. queueFx: function(anim) {
  91. var me = this,
  92. target = anim.target,
  93. queue, ln;
  94. if (!target) {
  95. return;
  96. }
  97. queue = me.getFxQueue(target.getId());
  98. ln = queue.length;
  99. if (ln) {
  100. if (anim.concurrent) {
  101. anim.paused = false;
  102. }
  103. else {
  104. queue[ln - 1].on('afteranimate', function() {
  105. anim.paused = false;
  106. });
  107. }
  108. }
  109. else {
  110. anim.paused = false;
  111. }
  112. anim.on('afteranimate', function() {
  113. Ext.Array.remove(queue, anim);
  114. if (anim.remove) {
  115. if (target.type == 'element') {
  116. var el = Ext.get(target.id);
  117. if (el) {
  118. el.remove();
  119. }
  120. }
  121. }
  122. }, this);
  123. queue.push(anim);
  124. }
  125. });</pre>
  126. </body>
  127. </html>