TransformInterface.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import ExpressionPropertyInterface from './ExpressionValueFactory';
  2. const TransformExpressionInterface = (function () {
  3. return function (transform) {
  4. function _thisFunction(name) {
  5. switch (name) {
  6. case 'scale':
  7. case 'Scale':
  8. case 'ADBE Scale':
  9. case 6:
  10. return _thisFunction.scale;
  11. case 'rotation':
  12. case 'Rotation':
  13. case 'ADBE Rotation':
  14. case 'ADBE Rotate Z':
  15. case 10:
  16. return _thisFunction.rotation;
  17. case 'ADBE Rotate X':
  18. return _thisFunction.xRotation;
  19. case 'ADBE Rotate Y':
  20. return _thisFunction.yRotation;
  21. case 'position':
  22. case 'Position':
  23. case 'ADBE Position':
  24. case 2:
  25. return _thisFunction.position;
  26. case 'ADBE Position_0':
  27. return _thisFunction.xPosition;
  28. case 'ADBE Position_1':
  29. return _thisFunction.yPosition;
  30. case 'ADBE Position_2':
  31. return _thisFunction.zPosition;
  32. case 'anchorPoint':
  33. case 'AnchorPoint':
  34. case 'Anchor Point':
  35. case 'ADBE AnchorPoint':
  36. case 1:
  37. return _thisFunction.anchorPoint;
  38. case 'opacity':
  39. case 'Opacity':
  40. case 11:
  41. return _thisFunction.opacity;
  42. default:
  43. return null;
  44. }
  45. }
  46. Object.defineProperty(_thisFunction, 'rotation', {
  47. get: ExpressionPropertyInterface(transform.r || transform.rz),
  48. });
  49. Object.defineProperty(_thisFunction, 'zRotation', {
  50. get: ExpressionPropertyInterface(transform.rz || transform.r),
  51. });
  52. Object.defineProperty(_thisFunction, 'xRotation', {
  53. get: ExpressionPropertyInterface(transform.rx),
  54. });
  55. Object.defineProperty(_thisFunction, 'yRotation', {
  56. get: ExpressionPropertyInterface(transform.ry),
  57. });
  58. Object.defineProperty(_thisFunction, 'scale', {
  59. get: ExpressionPropertyInterface(transform.s),
  60. });
  61. var _px;
  62. var _py;
  63. var _pz;
  64. var _transformFactory;
  65. if (transform.p) {
  66. _transformFactory = ExpressionPropertyInterface(transform.p);
  67. } else {
  68. _px = ExpressionPropertyInterface(transform.px);
  69. _py = ExpressionPropertyInterface(transform.py);
  70. if (transform.pz) {
  71. _pz = ExpressionPropertyInterface(transform.pz);
  72. }
  73. }
  74. Object.defineProperty(_thisFunction, 'position', {
  75. get: function () {
  76. if (transform.p) {
  77. return _transformFactory();
  78. }
  79. return [
  80. _px(),
  81. _py(),
  82. _pz ? _pz() : 0];
  83. },
  84. });
  85. Object.defineProperty(_thisFunction, 'xPosition', {
  86. get: ExpressionPropertyInterface(transform.px),
  87. });
  88. Object.defineProperty(_thisFunction, 'yPosition', {
  89. get: ExpressionPropertyInterface(transform.py),
  90. });
  91. Object.defineProperty(_thisFunction, 'zPosition', {
  92. get: ExpressionPropertyInterface(transform.pz),
  93. });
  94. Object.defineProperty(_thisFunction, 'anchorPoint', {
  95. get: ExpressionPropertyInterface(transform.a),
  96. });
  97. Object.defineProperty(_thisFunction, 'opacity', {
  98. get: ExpressionPropertyInterface(transform.o),
  99. });
  100. Object.defineProperty(_thisFunction, 'skew', {
  101. get: ExpressionPropertyInterface(transform.sk),
  102. });
  103. Object.defineProperty(_thisFunction, 'skewAxis', {
  104. get: ExpressionPropertyInterface(transform.sa),
  105. });
  106. Object.defineProperty(_thisFunction, 'orientation', {
  107. get: ExpressionPropertyInterface(transform.or),
  108. });
  109. return _thisFunction;
  110. };
  111. }());
  112. export default TransformExpressionInterface;