ElementCSS.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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-target-ElementCSS'>/**
  19. </span> * @class Ext.fx.target.ElementCSS
  20. *
  21. * This class represents a animation target for an {@link Ext.Element} that supports CSS
  22. * based animation. In general this class will not be created directly, the {@link Ext.Element}
  23. * will be passed to the animation and the appropriate target will be created.
  24. */
  25. Ext.define('Ext.fx.target.ElementCSS', {
  26. /* Begin Definitions */
  27. extend: 'Ext.fx.target.Element',
  28. /* End Definitions */
  29. setAttr: function(targetData, isFirstFrame) {
  30. var cssArr = {
  31. attrs: [],
  32. duration: [],
  33. easing: []
  34. },
  35. ln = targetData.length,
  36. attributes,
  37. attrs,
  38. attr,
  39. easing,
  40. duration,
  41. o,
  42. i,
  43. j,
  44. ln2;
  45. for (i = 0; i &lt; ln; i++) {
  46. attrs = targetData[i];
  47. duration = attrs.duration;
  48. easing = attrs.easing;
  49. attrs = attrs.attrs;
  50. for (attr in attrs) {
  51. if (Ext.Array.indexOf(cssArr.attrs, attr) == -1) {
  52. cssArr.attrs.push(attr.replace(/[A-Z]/g, function(v) {
  53. return '-' + v.toLowerCase();
  54. }));
  55. cssArr.duration.push(duration + 'ms');
  56. cssArr.easing.push(easing);
  57. }
  58. }
  59. }
  60. attributes = cssArr.attrs.join(',');
  61. duration = cssArr.duration.join(',');
  62. easing = cssArr.easing.join(', ');
  63. for (i = 0; i &lt; ln; i++) {
  64. attrs = targetData[i].attrs;
  65. for (attr in attrs) {
  66. ln2 = attrs[attr].length;
  67. for (j = 0; j &lt; ln2; j++) {
  68. o = attrs[attr][j];
  69. o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionProperty', isFirstFrame ? '' : attributes);
  70. o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionDuration', isFirstFrame ? '' : duration);
  71. o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionTimingFunction', isFirstFrame ? '' : easing);
  72. o[0].setStyle(attr, o[1]);
  73. // Must trigger reflow to make this get used as the start point for the transition that follows
  74. if (isFirstFrame) {
  75. o = o[0].dom.offsetWidth;
  76. }
  77. else {
  78. // Remove transition properties when completed.
  79. o[0].on(Ext.supports.CSS3TransitionEnd, function() {
  80. this.setStyle(Ext.supports.CSS3Prefix + 'TransitionProperty', null);
  81. this.setStyle(Ext.supports.CSS3Prefix + 'TransitionDuration', null);
  82. this.setStyle(Ext.supports.CSS3Prefix + 'TransitionTimingFunction', null);
  83. }, o[0], { single: true });
  84. }
  85. }
  86. }
  87. }
  88. }
  89. });</pre>
  90. </body>
  91. </html>