@akylas/nativescript 8.2.3 → 8.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/accessibility/index.ios.js +1 -1
  2. package/accessibility/index.ios.js.map +1 -1
  3. package/application/application-common.js.map +1 -1
  4. package/application/index.android.js.map +1 -1
  5. package/application/index.ios.d.ts +2 -0
  6. package/application/index.ios.js +7 -1
  7. package/application/index.ios.js.map +1 -1
  8. package/cli-hooks/before-checkForChanges.js +21 -16
  9. package/color/color-common.js +15 -9
  10. package/color/color-common.js.map +1 -1
  11. package/connectivity/index.android.js +11 -10
  12. package/connectivity/index.android.js.map +1 -1
  13. package/core-types/index.d.ts +1 -0
  14. package/core-types/index.js.map +1 -1
  15. package/css/LICENSE +9 -0
  16. package/css/Readme.md +278 -0
  17. package/css-value/LICENSE +9 -0
  18. package/css-value/Readme.md +45 -0
  19. package/css-value/UPGRADING.md +26 -0
  20. package/fetch/LICENSE +20 -0
  21. package/fetch/README.md +1 -0
  22. package/image-source/index.android.js +4 -7
  23. package/image-source/index.android.js.map +1 -1
  24. package/image-source/index.ios.js +3 -9
  25. package/image-source/index.ios.js.map +1 -1
  26. package/index.d.ts +8 -2
  27. package/index.js +13 -2
  28. package/index.js.map +1 -1
  29. package/jest.config.d.ts +5 -0
  30. package/jest.config.js.map +1 -0
  31. package/js-libs/easysax/LICENSE +20 -0
  32. package/js-libs/easysax/README.md +46 -0
  33. package/js-libs/esprima/LICENSE.BSD +19 -0
  34. package/js-libs/esprima/README.md +24 -0
  35. package/js-libs/polymer-expressions/LICENSE +27 -0
  36. package/js-libs/polymer-expressions/README.md +0 -0
  37. package/package.json +5 -13
  38. package/platforms/README.md +1 -0
  39. package/platforms/android/widgets-release.aar +0 -0
  40. package/platforms/ios/TNSWidgets.xcframework/Info.plist +17 -0
  41. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
  42. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  43. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  44. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  45. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  46. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  47. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  48. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSWidgets.h +24 -0
  49. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  50. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  51. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Modules/module.modulemap +6 -0
  52. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  53. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  54. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +52 -0
  55. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/TNSWidgets +0 -0
  56. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSData+Async.h +24 -0
  57. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSString+Async.h +25 -0
  58. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSLabel.h +16 -0
  59. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSProcess.h +29 -0
  60. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSWidgets.h +24 -0
  61. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIImage+TNSBlocks.h +26 -0
  62. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIView+PassThroughParent.h +17 -0
  63. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Modules/module.modulemap +6 -0
  64. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/NSObject+Swizzling.h +17 -0
  65. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/UIView+PropertyBag.h +18 -0
  66. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +52 -0
  67. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
  68. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
  69. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  70. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  71. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  72. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  73. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
  74. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  75. package/ui/animation/animation-common.d.ts +7 -4
  76. package/ui/animation/animation-common.js +55 -117
  77. package/ui/animation/animation-common.js.map +1 -1
  78. package/ui/animation/animation-interfaces.d.ts +3 -2
  79. package/ui/animation/index.android.d.ts +15 -14
  80. package/ui/animation/index.android.js +94 -20
  81. package/ui/animation/index.android.js.map +1 -1
  82. package/ui/animation/index.ios.d.ts +33 -16
  83. package/ui/animation/index.ios.js +256 -202
  84. package/ui/animation/index.ios.js.map +1 -1
  85. package/ui/animation/keyframe-animation.d.ts +0 -1
  86. package/ui/animation/keyframe-animation.js +51 -51
  87. package/ui/animation/keyframe-animation.js.map +1 -1
  88. package/ui/button/index.ios.js +1 -1
  89. package/ui/button/index.ios.js.map +1 -1
  90. package/ui/core/properties/index.d.ts +37 -6
  91. package/ui/core/properties/index.js +434 -643
  92. package/ui/core/properties/index.js.map +1 -1
  93. package/ui/core/view/index.d.ts +5 -0
  94. package/ui/core/view/index.ios.d.ts +4 -2
  95. package/ui/core/view/index.ios.js +33 -10
  96. package/ui/core/view/index.ios.js.map +1 -1
  97. package/ui/core/view/view-common.d.ts +1 -0
  98. package/ui/core/view/view-common.js +6 -3
  99. package/ui/core/view/view-common.js.map +1 -1
  100. package/ui/core/view/view-helper/index.ios.d.ts +2 -0
  101. package/ui/core/view/view-helper/index.ios.js +13 -4
  102. package/ui/core/view/view-helper/index.ios.js.map +1 -1
  103. package/ui/core/view-base/index.js +4 -5
  104. package/ui/core/view-base/index.js.map +1 -1
  105. package/ui/editable-text-base/editable-text-base-common.js +2 -1
  106. package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
  107. package/ui/frame/frame-common.d.ts +1 -1
  108. package/ui/frame/frame-common.js +17 -17
  109. package/ui/frame/frame-common.js.map +1 -1
  110. package/ui/frame/index.android.js +6 -2
  111. package/ui/frame/index.android.js.map +1 -1
  112. package/ui/frame/index.ios.js +2 -0
  113. package/ui/frame/index.ios.js.map +1 -1
  114. package/ui/html-view/html-view-common.js +2 -1
  115. package/ui/html-view/html-view-common.js.map +1 -1
  116. package/ui/image/image-common.js +2 -2
  117. package/ui/image/image-common.js.map +1 -1
  118. package/ui/label/index.ios.js +2 -2
  119. package/ui/label/index.ios.js.map +1 -1
  120. package/ui/layouts/root-layout/root-layout-common.js +6 -4
  121. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  122. package/ui/list-view/list-view-common.js +2 -2
  123. package/ui/list-view/list-view-common.js.map +1 -1
  124. package/ui/page/index.ios.d.ts +1 -0
  125. package/ui/page/index.ios.js +5 -0
  126. package/ui/page/index.ios.js.map +1 -1
  127. package/ui/page/page-common.js +2 -1
  128. package/ui/page/page-common.js.map +1 -1
  129. package/ui/proxy-view-container/index.d.ts +2 -0
  130. package/ui/proxy-view-container/index.js +28 -0
  131. package/ui/proxy-view-container/index.js.map +1 -1
  132. package/ui/search-bar/search-bar-common.js +3 -2
  133. package/ui/search-bar/search-bar-common.js.map +1 -1
  134. package/ui/segmented-bar/segmented-bar-common.js +2 -1
  135. package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
  136. package/ui/styling/css-animation-parser.js +3 -2
  137. package/ui/styling/css-animation-parser.js.map +1 -1
  138. package/ui/styling/font.ios.js +23 -2
  139. package/ui/styling/font.ios.js.map +1 -1
  140. package/ui/styling/style/index.d.ts +3 -1
  141. package/ui/styling/style/index.js +6 -0
  142. package/ui/styling/style/index.js.map +1 -1
  143. package/ui/styling/style-properties.d.ts +1 -0
  144. package/ui/styling/style-properties.js +57 -69
  145. package/ui/styling/style-properties.js.map +1 -1
  146. package/ui/styling/style-scope.js +4 -10
  147. package/ui/styling/style-scope.js.map +1 -1
  148. package/ui/switch/index.android.js +8 -6
  149. package/ui/switch/index.android.js.map +1 -1
  150. package/ui/switch/switch-common.js +2 -1
  151. package/ui/switch/switch-common.js.map +1 -1
  152. package/ui/tab-view/index.ios.d.ts +1 -0
  153. package/ui/tab-view/index.ios.js +54 -24
  154. package/ui/tab-view/index.ios.js.map +1 -1
  155. package/ui/tab-view/tab-view-common.js +5 -4
  156. package/ui/tab-view/tab-view-common.js.map +1 -1
  157. package/ui/text-base/index.android.js +1 -1
  158. package/ui/text-base/index.android.js.map +1 -1
  159. package/ui/text-base/index.d.ts +5 -0
  160. package/ui/text-base/index.ios.js +4 -3
  161. package/ui/text-base/index.ios.js.map +1 -1
  162. package/ui/text-base/text-base-common.d.ts +3 -3
  163. package/ui/text-base/text-base-common.js +1 -1
  164. package/ui/text-base/text-base-common.js.map +1 -1
  165. package/ui/web-view/index.android.js +4 -2
  166. package/ui/web-view/index.android.js.map +1 -1
  167. package/utils/index.android.d.ts +1 -1
  168. package/utils/index.android.js +1 -1
  169. package/utils/index.android.js.map +1 -1
  170. package/utils/index.ios.d.ts +1 -1
  171. package/utils/index.ios.js +1 -1
  172. package/utils/index.ios.js.map +1 -1
  173. package/utils/mainthread-helper.ios.d.ts +1 -1
  174. package/utils/mainthread-helper.ios.js +7 -9
  175. package/utils/mainthread-helper.ios.js.map +1 -1
  176. package/utils/native-helper.android.d.ts +2 -0
  177. package/utils/native-helper.android.js +127 -0
  178. package/utils/native-helper.android.js.map +1 -1
  179. package/utils/native-helper.d.ts +22 -0
  180. package/utils/native-helper.ios.d.ts +3 -0
  181. package/utils/native-helper.ios.js +90 -0
  182. package/utils/native-helper.ios.js.map +1 -1
  183. package/utils/types.d.ts +2 -0
  184. package/utils/types.js +6 -0
  185. package/utils/types.js.map +1 -1
  186. package/platforms/android/core.aar +0 -0
  187. package/platforms/android/nativescript.aar +0 -0
@@ -1,82 +1,85 @@
1
1
  // Requires
2
2
  import { AnimationBase, Properties, CubicBezierAnimationCurve } from './animation-common';
3
3
  import { Trace } from '../../trace';
4
- import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty, PercentLength } from '../styling/style-properties';
4
+ import { rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty, PercentLength } from '../styling/style-properties';
5
5
  import { iOSNativeHelper } from '../../utils/native-helper';
6
6
  import { Screen } from '../../platform';
7
+ import { Color } from '../../color';
7
8
  export * from './animation-common';
8
9
  export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation';
9
10
  const _transform = '_transform';
10
11
  const _skip = '_skip';
11
- const FLT_MAX = 340282346638528859811704183484516925440.0;
12
12
  class AnimationInfo {
13
13
  }
14
+ export function applyAnimationProperty(styleOrView, property, value, setKeyFrame) {
15
+ styleOrView[setKeyFrame && property['keyframe'] ? property['keyframe'] : property.name] = value;
16
+ }
14
17
  var AnimationDelegateImpl = /** @class */ (function (_super) {
15
18
  __extends(AnimationDelegateImpl, _super);
16
19
  function AnimationDelegateImpl() {
17
20
  return _super !== null && _super.apply(this, arguments) || this;
18
21
  }
19
- AnimationDelegateImpl.initWithFinishedCallback = function (finishedCallback, propertyAnimation, valueSource) {
22
+ AnimationDelegateImpl.initWithFinishedCallback = function (animation, propertyAnimation) {
20
23
  var delegate = AnimationDelegateImpl.new();
21
- delegate._finishedCallback = finishedCallback;
24
+ delegate._animation = animation;
22
25
  delegate._propertyAnimation = propertyAnimation;
23
- delegate._valueSource = valueSource;
24
26
  return delegate;
25
27
  };
26
28
  AnimationDelegateImpl.prototype.animationDidStart = function (anim) {
29
+ var _a;
27
30
  var value = this._propertyAnimation.value;
28
- var setLocal = this._valueSource === 'animation';
31
+ var animation = (_a = this._animation) === null || _a === void 0 ? void 0 : _a.get();
32
+ var setKeyFrame = (animation === null || animation === void 0 ? void 0 : animation.valueSource) === 'keyframe';
29
33
  var targetStyle = this._propertyAnimation.target.style;
30
34
  this._propertyAnimation.target._suspendPresentationLayerUpdates();
31
- switch (this._propertyAnimation.property) {
32
- case Properties.backgroundColor:
33
- targetStyle[setLocal ? backgroundColorProperty.name : backgroundColorProperty.keyframe] = value;
34
- break;
35
- case Properties.opacity:
36
- targetStyle[setLocal ? opacityProperty.name : opacityProperty.keyframe] = value;
37
- break;
35
+ switch (this._propertyAnimation.propertyName) {
38
36
  case Properties.rotate:
39
- targetStyle[setLocal ? rotateXProperty.name : rotateXProperty.keyframe] = value.x;
40
- targetStyle[setLocal ? rotateYProperty.name : rotateYProperty.keyframe] = value.y;
41
- targetStyle[setLocal ? rotateProperty.name : rotateProperty.keyframe] = value.z;
37
+ applyAnimationProperty(targetStyle, rotateXProperty, value.x, setKeyFrame);
38
+ applyAnimationProperty(targetStyle, rotateYProperty, value.y, setKeyFrame);
39
+ applyAnimationProperty(targetStyle, rotateProperty, value.z, setKeyFrame);
42
40
  break;
43
41
  case Properties.translate:
44
- targetStyle[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value.x;
45
- targetStyle[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value.y;
46
- break;
47
- case Properties.height:
48
- targetStyle[setLocal ? heightProperty.name : heightProperty.keyframe] = value;
49
- break;
50
- case Properties.width:
51
- targetStyle[setLocal ? widthProperty.name : widthProperty.keyframe] = value;
42
+ applyAnimationProperty(targetStyle, translateXProperty, value.x, setKeyFrame);
43
+ applyAnimationProperty(targetStyle, translateYProperty, value.y, setKeyFrame);
52
44
  break;
53
45
  case Properties.scale:
54
- targetStyle[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = value.x === 0 ? 0.001 : value.x;
55
- targetStyle[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.y === 0 ? 0.001 : value.y;
46
+ applyAnimationProperty(targetStyle, scaleXProperty, value.x || 1e-6, setKeyFrame);
47
+ applyAnimationProperty(targetStyle, scaleYProperty, value.y || 1e-6, setKeyFrame);
56
48
  break;
57
49
  case _transform:
58
- if (value[Properties.translate] !== undefined) {
59
- targetStyle[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value[Properties.translate].x;
60
- targetStyle[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value[Properties.translate].y;
50
+ var translateValue = value[Properties.rotate];
51
+ if (translateValue !== undefined) {
52
+ applyAnimationProperty(targetStyle, translateXProperty, translateValue.x, setKeyFrame);
53
+ applyAnimationProperty(targetStyle, translateYProperty, translateValue.y, setKeyFrame);
61
54
  }
62
- if (value[Properties.rotate] !== undefined) {
63
- targetStyle[setLocal ? rotateXProperty.name : rotateXProperty.keyframe] = value[Properties.rotate].x;
64
- targetStyle[setLocal ? rotateYProperty.name : rotateYProperty.keyframe] = value[Properties.rotate].y;
65
- targetStyle[setLocal ? rotateProperty.name : rotateProperty.keyframe] = value[Properties.rotate].z;
55
+ var rotateValue = value[Properties.rotate];
56
+ if (rotateValue !== undefined) {
57
+ applyAnimationProperty(targetStyle, rotateXProperty, rotateValue.x, setKeyFrame);
58
+ applyAnimationProperty(targetStyle, rotateYProperty, rotateValue.y, setKeyFrame);
59
+ applyAnimationProperty(targetStyle, rotateProperty, rotateValue.z, setKeyFrame);
66
60
  }
67
- if (value[Properties.scale] !== undefined) {
68
- var x = value[Properties.scale].x;
69
- var y = value[Properties.scale].y;
70
- targetStyle[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = x === 0 ? 0.001 : x;
71
- targetStyle[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = y === 0 ? 0.001 : y;
61
+ var scaleValue = value[Properties.scale];
62
+ if (scaleValue !== undefined) {
63
+ var x = scaleValue.x;
64
+ var y = scaleValue.y;
65
+ applyAnimationProperty(targetStyle, scaleXProperty, scaleValue.x || 1e-6, setKeyFrame);
66
+ applyAnimationProperty(targetStyle, scaleYProperty, scaleValue.y || 1e-6, setKeyFrame);
67
+ }
68
+ break;
69
+ default:
70
+ var property = this._propertyAnimation.property;
71
+ if (property) {
72
+ applyAnimationProperty(targetStyle, property, value, setKeyFrame);
72
73
  }
73
74
  break;
74
75
  }
75
76
  this._propertyAnimation.target._resumePresentationLayerUpdates();
76
77
  };
77
78
  AnimationDelegateImpl.prototype.animationDidStopFinished = function (anim, finished) {
78
- if (this._finishedCallback) {
79
- this._finishedCallback(!finished);
79
+ var _a;
80
+ var animation = (_a = this._animation) === null || _a === void 0 ? void 0 : _a.get();
81
+ if (animation) {
82
+ animation.animationFinishedCallback(!finished);
80
83
  }
81
84
  if (finished && this.nextAnimation) {
82
85
  this.nextAnimation();
@@ -116,6 +119,8 @@ export function _resolveAnimationCurve(curve) {
116
119
  export class Animation extends AnimationBase {
117
120
  constructor(animationDefinitions, playSequentially) {
118
121
  super(animationDefinitions, playSequentially);
122
+ this._wasCancelled = false;
123
+ this.usePropertyAnimator = false;
119
124
  this._valueSource = 'animation';
120
125
  if (animationDefinitions.length > 0 && animationDefinitions[0].valueSource !== undefined) {
121
126
  this._valueSource = animationDefinitions[0].valueSource;
@@ -132,46 +137,49 @@ export class Animation extends AnimationBase {
132
137
  else {
133
138
  this._mergedPropertyAnimations = this._propertyAnimations;
134
139
  }
135
- const that = this;
136
- const animationFinishedCallback = (cancelled) => {
137
- if (that._playSequentially) {
138
- // This function will be called by the last animation when done or by another animation if the user cancels them halfway through.
139
- if (cancelled) {
140
- that._rejectAnimationFinishedPromise();
141
- }
142
- else {
143
- that._resolveAnimationFinishedPromise();
144
- }
140
+ this._iOSAnimationFunction = this._createiOSAnimationFunction(this._mergedPropertyAnimations, 0, this._playSequentially);
141
+ }
142
+ get valueSource() {
143
+ return this._valueSource;
144
+ }
145
+ animationFinishedCallback(cancelled) {
146
+ if (this._playSequentially) {
147
+ // This function will be called by the last animation when done or by another animation if the user cancels them halfway through.
148
+ if (cancelled) {
149
+ this._rejectAnimationFinishedPromise();
145
150
  }
146
151
  else {
147
- // This callback will be called by each INDIVIDUAL animation when it finishes or is cancelled.
148
- if (cancelled) {
149
- that._cancelledAnimations++;
150
- }
151
- else {
152
- that._finishedAnimations++;
153
- }
154
- if (that._cancelledAnimations > 0 && that._cancelledAnimations + that._finishedAnimations === that._mergedPropertyAnimations.length) {
155
- if (Trace.isEnabled()) {
156
- Trace.write(that._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation);
157
- }
158
- that._rejectAnimationFinishedPromise();
152
+ this._resolveAnimationFinishedPromise();
153
+ }
154
+ }
155
+ else {
156
+ // This callback will be called by each INDIVIDUAL animation when it finishes or is cancelled.
157
+ if (cancelled) {
158
+ this._cancelledAnimations++;
159
+ }
160
+ else {
161
+ this._finishedAnimations++;
162
+ }
163
+ if (this._cancelledAnimations > 0 && this._cancelledAnimations + this._finishedAnimations === this._mergedPropertyAnimations.length) {
164
+ if (Trace.isEnabled()) {
165
+ Trace.write(this._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation);
159
166
  }
160
- else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
161
- if (Trace.isEnabled()) {
162
- Trace.write(that._finishedAnimations + ' animations finished.', Trace.categories.Animation);
163
- }
164
- that._resolveAnimationFinishedPromise();
167
+ this._rejectAnimationFinishedPromise();
168
+ }
169
+ else if (this._finishedAnimations === this._mergedPropertyAnimations.length) {
170
+ if (Trace.isEnabled()) {
171
+ Trace.write(this._finishedAnimations + ' animations finished.', Trace.categories.Animation);
165
172
  }
173
+ this._resolveAnimationFinishedPromise();
166
174
  }
167
- };
168
- this._iOSAnimationFunction = Animation._createiOSAnimationFunction(this._mergedPropertyAnimations, 0, this._playSequentially, this._valueSource, animationFinishedCallback);
175
+ }
169
176
  }
170
177
  play() {
171
178
  if (this.isPlaying) {
172
179
  return this._rejectAlreadyPlaying();
173
180
  }
174
181
  const animationFinishedPromise = super.play();
182
+ this._wasCancelled = false;
175
183
  this._finishedAnimations = 0;
176
184
  this._cancelledAnimations = 0;
177
185
  this._iOSAnimationFunction();
@@ -182,6 +190,11 @@ export class Animation extends AnimationBase {
182
190
  Trace.write('Animation is not currently playing.', Trace.categories.Animation, Trace.messageType.warn);
183
191
  return;
184
192
  }
193
+ this._wasCancelled = true;
194
+ // this._iOSAnimators.forEach((animator) => {
195
+ // animator.stopAnimation(false);
196
+ // animator.finishAnimationAtPosition(UIViewAnimatingPosition.Current);
197
+ // });
185
198
  let i = 0;
186
199
  const length = this._mergedPropertyAnimations.length;
187
200
  for (; i < length; i++) {
@@ -195,64 +208,40 @@ export class Animation extends AnimationBase {
195
208
  _resolveAnimationCurve(curve) {
196
209
  return _resolveAnimationCurve(curve);
197
210
  }
198
- static _createiOSAnimationFunction(propertyAnimations, index, playSequentially, valueSource, finishedCallback) {
211
+ _createiOSAnimationFunction(propertyAnimations, index, playSequentially) {
199
212
  return (cancelled) => {
200
- if (cancelled && finishedCallback) {
213
+ if (cancelled) {
201
214
  if (Trace.isEnabled()) {
202
215
  Trace.write('Animation ' + (index - 1).toString() + ' was cancelled. Will skip the rest of animations and call finishedCallback(true).', Trace.categories.Animation);
203
216
  }
204
- finishedCallback(cancelled);
217
+ this.animationFinishedCallback(cancelled);
205
218
  return;
206
219
  }
207
- const animation = propertyAnimations[index];
208
- const args = Animation._getNativeAnimationArguments(animation, valueSource);
209
- if (animation.curve === 'spring') {
210
- Animation._createNativeSpringAnimation(propertyAnimations, index, playSequentially, args, animation, valueSource, finishedCallback);
211
- }
212
- else {
213
- Animation._createNativeAnimation(propertyAnimations, index, playSequentially, args, animation, valueSource, finishedCallback);
214
- }
220
+ const animationInfo = propertyAnimations[index];
221
+ this._createNativeUIViewAnimation(propertyAnimations, index, playSequentially, animationInfo);
215
222
  };
216
223
  }
217
- static _getNativeAnimationArguments(animation, valueSource) {
224
+ _getNativeAnimationArguments(animation, useCABasicAnimation = false) {
218
225
  const view = animation.target;
219
226
  const style = view.style;
220
227
  const nativeView = view.nativeViewProtected;
221
228
  const parent = view.parent;
222
- let propertyNameToAnimate = animation.property;
229
+ let propertyNameToAnimate = animation.propertyName;
223
230
  let subPropertyNameToAnimate;
224
231
  let toValue = animation.value;
225
232
  let fromValue;
226
- const setLocal = valueSource === 'animation';
227
- switch (animation.property) {
228
- case Properties.backgroundColor:
229
- animation._originalValue = view.backgroundColor;
230
- animation._propertyResetCallback = (value, valueSource) => {
231
- style[setLocal ? backgroundColorProperty.name : backgroundColorProperty.keyframe] = value;
232
- };
233
- fromValue = nativeView.layer.backgroundColor;
234
- if (nativeView instanceof UILabel) {
235
- nativeView.setValueForKey(UIColor.clearColor, 'backgroundColor');
236
- }
237
- toValue = toValue.CGColor;
238
- break;
239
- case Properties.opacity:
240
- animation._originalValue = view.opacity;
241
- animation._propertyResetCallback = (value, valueSource) => {
242
- style[setLocal ? opacityProperty.name : opacityProperty.keyframe] = value;
243
- };
244
- fromValue = nativeView.layer.opacity;
245
- break;
233
+ const setKeyFrame = this._valueSource === 'keyframe';
234
+ switch (animation.propertyName) {
246
235
  case Properties.rotate:
247
236
  animation._originalValue = {
248
237
  x: view.rotateX,
249
238
  y: view.rotateY,
250
239
  z: view.rotate,
251
240
  };
252
- animation._propertyResetCallback = (value, valueSource) => {
253
- style[setLocal ? rotateProperty.name : rotateProperty.keyframe] = value.z;
254
- style[setLocal ? rotateXProperty.name : rotateXProperty.keyframe] = value.x;
255
- style[setLocal ? rotateYProperty.name : rotateYProperty.keyframe] = value.y;
241
+ animation._propertyResetCallback = (value) => {
242
+ applyAnimationProperty(style, rotateXProperty, value.x, setKeyFrame);
243
+ applyAnimationProperty(style, rotateYProperty, value.y, setKeyFrame);
244
+ applyAnimationProperty(style, rotateProperty, value.z, setKeyFrame);
256
245
  };
257
246
  propertyNameToAnimate = 'transform.rotation';
258
247
  subPropertyNameToAnimate = ['x', 'y', 'z'];
@@ -283,24 +272,20 @@ export class Animation extends AnimationBase {
283
272
  y: view.translateY,
284
273
  };
285
274
  animation._propertyResetCallback = (value, valueSource) => {
286
- style[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value.x;
287
- style[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value.y;
275
+ applyAnimationProperty(style, translateXProperty, value.x, setKeyFrame);
276
+ applyAnimationProperty(style, translateYProperty, value.y, setKeyFrame);
288
277
  };
289
278
  propertyNameToAnimate = 'transform';
290
279
  fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
291
280
  toValue = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, toValue.x, toValue.y, 0));
292
281
  break;
293
282
  case Properties.scale:
294
- if (toValue.x === 0) {
295
- toValue.x = 0.001;
296
- }
297
- if (toValue.y === 0) {
298
- toValue.y = 0.001;
299
- }
283
+ toValue.x = toValue.x || 1e-6;
284
+ toValue.y = toValue.y || 1e-6;
300
285
  animation._originalValue = { x: view.scaleX, y: view.scaleY };
301
286
  animation._propertyResetCallback = (value, valueSource) => {
302
- style[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = value.x;
303
- style[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.y;
287
+ applyAnimationProperty(style, scaleXProperty, value.x, setKeyFrame);
288
+ applyAnimationProperty(style, scaleYProperty, value.y, setKeyFrame);
304
289
  };
305
290
  propertyNameToAnimate = 'transform';
306
291
  fromValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
@@ -318,41 +303,64 @@ export class Animation extends AnimationBase {
318
303
  rz: view.rotate,
319
304
  };
320
305
  animation._propertyResetCallback = (value, valueSource) => {
321
- style[setLocal ? translateXProperty.name : translateXProperty.keyframe] = value.xt;
322
- style[setLocal ? translateYProperty.name : translateYProperty.keyframe] = value.yt;
323
- style[setLocal ? scaleXProperty.name : scaleXProperty.keyframe] = value.xs;
324
- style[setLocal ? scaleYProperty.name : scaleYProperty.keyframe] = value.ys;
325
- style[setLocal ? rotateXProperty.name : rotateXProperty.keyframe] = value.rx;
326
- style[setLocal ? rotateYProperty.name : rotateYProperty.keyframe] = value.ry;
327
- style[setLocal ? rotateProperty.name : rotateProperty.keyframe] = value.rz;
306
+ applyAnimationProperty(style, translateXProperty, value.xt, setKeyFrame);
307
+ applyAnimationProperty(style, translateYProperty, value.yt, setKeyFrame);
308
+ applyAnimationProperty(style, scaleXProperty, value.xs, setKeyFrame);
309
+ applyAnimationProperty(style, scaleYProperty, value.ys, setKeyFrame);
310
+ applyAnimationProperty(style, rotateXProperty, value.rx, setKeyFrame);
311
+ applyAnimationProperty(style, rotateYProperty, value.ry, setKeyFrame);
312
+ applyAnimationProperty(style, rotateProperty, value.rz, setKeyFrame);
328
313
  };
329
314
  propertyNameToAnimate = 'transform';
330
315
  toValue = NSValue.valueWithCATransform3D(Animation._createNativeAffineTransform(animation));
331
316
  break;
332
317
  case Properties.width:
333
318
  case Properties.height: {
334
- const direction = animation.property;
335
- const isHeight = direction === 'height';
336
- propertyNameToAnimate = 'bounds';
337
- if (!parent) {
338
- throw new Error(`cannot animate ${direction} on root view`);
319
+ if (useCABasicAnimation) {
320
+ const direction = animation.propertyName;
321
+ const isHeight = direction === 'height';
322
+ propertyNameToAnimate = 'bounds';
323
+ if (!parent) {
324
+ throw new Error(`cannot animate ${direction} on root view`);
325
+ }
326
+ const parentExtent = isHeight ? parent.getMeasuredHeight() : parent.getMeasuredWidth();
327
+ const asNumber = PercentLength.toDevicePixels(PercentLength.parse(toValue), parentExtent, parentExtent) / Screen.mainScreen.scale;
328
+ const currentBounds = nativeView.layer.bounds;
329
+ const extentX = isHeight ? currentBounds.size.width : asNumber;
330
+ const extentY = isHeight ? asNumber : currentBounds.size.height;
331
+ fromValue = NSValue.valueWithCGRect(currentBounds);
332
+ toValue = NSValue.valueWithCGRect(CGRectMake(currentBounds.origin.x, currentBounds.origin.y, extentX, extentY));
333
+ animation._originalValue = view.height;
334
+ animation._propertyResetCallback = (value) => {
335
+ const prop = isHeight ? heightProperty : widthProperty;
336
+ applyAnimationProperty(style, prop, value, setKeyFrame);
337
+ };
338
+ break;
339
339
  }
340
- const parentExtent = isHeight ? parent.getMeasuredHeight() : parent.getMeasuredWidth();
341
- const asNumber = PercentLength.toDevicePixels(PercentLength.parse(toValue), parentExtent, parentExtent) / Screen.mainScreen.scale;
342
- const currentBounds = nativeView.layer.bounds;
343
- const extentX = isHeight ? currentBounds.size.width : asNumber;
344
- const extentY = isHeight ? asNumber : currentBounds.size.height;
345
- fromValue = NSValue.valueWithCGRect(currentBounds);
346
- toValue = NSValue.valueWithCGRect(CGRectMake(currentBounds.origin.x, currentBounds.origin.y, extentX, extentY));
347
- animation._originalValue = view.height;
348
- animation._propertyResetCallback = (value, valueSource) => {
349
- const prop = isHeight ? heightProperty : widthProperty;
350
- style[setLocal ? prop.name : prop.keyframe] = value;
351
- };
352
- break;
353
340
  }
354
341
  default:
355
- throw new Error(`Animating property '${animation.property}' is unsupported`);
342
+ if (animation.property) {
343
+ // animation._originalValue = view.backgroundColor;
344
+ animation._originalValue = animation.target.style[animation.property.name];
345
+ animation._propertyResetCallback = (value) => {
346
+ applyAnimationProperty(style, animation.property, value, setKeyFrame);
347
+ };
348
+ fromValue = animation._originalValue;
349
+ if (animation._originalValue instanceof Color) {
350
+ animation._originalValue = animation._originalValue;
351
+ fromValue = animation._originalValue.ios.CGColor;
352
+ }
353
+ if (toValue instanceof Color) {
354
+ if (nativeView instanceof UILabel) {
355
+ nativeView.setValueForKey(UIColor.clearColor, 'backgroundColor');
356
+ }
357
+ toValue = toValue.ios.CGColor;
358
+ }
359
+ }
360
+ else {
361
+ throw new Error(`Animating property '${propertyNameToAnimate}' is unsupported`);
362
+ }
363
+ break;
356
364
  }
357
365
  let duration = 0.3;
358
366
  if (animation.duration !== undefined) {
@@ -365,7 +373,7 @@ export class Animation extends AnimationBase {
365
373
  let repeatCount = undefined;
366
374
  if (animation.iterations !== undefined) {
367
375
  if (animation.iterations === Number.POSITIVE_INFINITY) {
368
- repeatCount = FLT_MAX;
376
+ repeatCount = Number.MAX_VALUE;
369
377
  }
370
378
  else {
371
379
  repeatCount = animation.iterations;
@@ -381,21 +389,23 @@ export class Animation extends AnimationBase {
381
389
  delay: delay,
382
390
  };
383
391
  }
384
- static _createNativeAnimation(propertyAnimations, index, playSequentially, args, animation, valueSource, finishedCallback) {
385
- const nativeView = animation.target.nativeViewProtected;
392
+ _createNativeAnimation(propertyAnimations, index, playSequentially) {
393
+ const animationInfo = propertyAnimations[index];
394
+ const args = this._getNativeAnimationArguments(animationInfo, true);
395
+ const nativeView = animationInfo.target.nativeViewProtected;
386
396
  let nativeAnimation;
387
397
  if (args.subPropertiesToAnimate) {
388
- nativeAnimation = this._createGroupAnimation(args, animation);
398
+ nativeAnimation = this._createGroupAnimation(args, animationInfo);
389
399
  }
390
400
  else {
391
- nativeAnimation = this._createBasicAnimation(args, animation);
401
+ nativeAnimation = this._createBasicAnimation(args, animationInfo);
392
402
  }
393
- const animationDelegate = AnimationDelegateImpl.initWithFinishedCallback(finishedCallback, animation, valueSource);
403
+ const animationDelegate = AnimationDelegateImpl.initWithFinishedCallback(new WeakRef(this), animationInfo);
394
404
  nativeAnimation.setValueForKey(animationDelegate, 'delegate');
395
405
  nativeView.layer.addAnimationForKey(nativeAnimation, args.propertyNameToAnimate);
396
406
  let callback = undefined;
397
407
  if (index + 1 < propertyAnimations.length) {
398
- callback = Animation._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially, valueSource, finishedCallback);
408
+ callback = this._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially);
399
409
  if (!playSequentially) {
400
410
  callback();
401
411
  }
@@ -404,7 +414,7 @@ export class Animation extends AnimationBase {
404
414
  }
405
415
  }
406
416
  }
407
- static _createGroupAnimation(args, animation) {
417
+ _createGroupAnimation(args, animation) {
408
418
  const groupAnimation = CAAnimationGroup.new();
409
419
  groupAnimation.duration = args.duration;
410
420
  if (args.repeatCount !== undefined) {
@@ -428,8 +438,9 @@ export class Animation extends AnimationBase {
428
438
  groupAnimation.animations = animations;
429
439
  return groupAnimation;
430
440
  }
431
- static _createBasicAnimation(args, animation) {
432
- const basicAnimation = CABasicAnimation.animationWithKeyPath(args.propertyNameToAnimate);
441
+ _createBasicAnimation(args, animation) {
442
+ const basicAnimation = (animation.curve === 'spring' ? CASpringAnimation : CABasicAnimation).animationWithKeyPath(args.propertyNameToAnimate);
443
+ basicAnimation['damping'] = 0.2;
433
444
  basicAnimation.fromValue = args.fromValue;
434
445
  basicAnimation.toValue = args.toValue;
435
446
  basicAnimation.duration = args.duration;
@@ -444,12 +455,13 @@ export class Animation extends AnimationBase {
444
455
  }
445
456
  return basicAnimation;
446
457
  }
447
- static _createNativeSpringAnimation(propertyAnimations, index, playSequentially, args, animation, valueSource, finishedCallback) {
448
- const nativeView = animation.target.nativeViewProtected;
458
+ _createNativeUIViewAnimation(propertyAnimations, index, playSequentially, animationInfo) {
459
+ const args = this._getNativeAnimationArguments(animationInfo);
460
+ const nativeView = animationInfo.target.nativeViewProtected;
449
461
  let callback = undefined;
450
462
  let nextAnimation;
451
463
  if (index + 1 < propertyAnimations.length) {
452
- callback = Animation._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially, valueSource, finishedCallback);
464
+ callback = this._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially);
453
465
  if (!playSequentially) {
454
466
  callback();
455
467
  }
@@ -461,64 +473,94 @@ export class Animation extends AnimationBase {
461
473
  if (args.delay) {
462
474
  delay = args.delay;
463
475
  }
464
- UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(args.duration, delay, 0.2, 0, 196608 /* CurveLinear */, () => {
476
+ const isSpring = animationInfo.curve === 'spring';
477
+ let animationOptions = 2 /* AllowUserInteraction */;
478
+ const animate = () => {
465
479
  if (args.repeatCount !== undefined) {
466
480
  UIView.setAnimationRepeatCount(args.repeatCount);
467
481
  }
468
- switch (animation.property) {
469
- case Properties.backgroundColor:
470
- animation.target.backgroundColor = args.toValue;
471
- break;
472
- case Properties.opacity:
473
- animation.target.opacity = args.toValue;
474
- break;
475
- case Properties.height:
476
- case Properties.width:
477
- animation._originalValue = animation.target[animation.property];
478
- nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);
479
- animation._propertyResetCallback = function (value) {
480
- animation.target[animation.property] = value;
481
- };
482
- break;
482
+ const setKeyFrame = this._valueSource === 'keyframe';
483
+ switch (animationInfo.propertyName) {
483
484
  case _transform:
484
- animation._originalValue = nativeView.layer.transform;
485
+ animationInfo._originalValue = nativeView.layer.transform;
485
486
  nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);
486
- animation._propertyResetCallback = function (value) {
487
+ animationInfo._propertyResetCallback = function (value) {
487
488
  nativeView.layer.transform = value;
488
489
  };
489
490
  break;
491
+ default:
492
+ applyAnimationProperty(animationInfo.target, animationInfo.property, animationInfo.value, setKeyFrame);
493
+ if (animationInfo.property.affectsLayout) {
494
+ (animationInfo.target.page || animationInfo.target).nativeViewProtected.layoutIfNeeded();
495
+ }
496
+ break;
490
497
  }
491
- }, function (animationDidFinish) {
498
+ };
499
+ const finish = (animationDidFinish) => {
492
500
  if (animationDidFinish) {
493
- if (animation.property === _transform) {
494
- if (animation.value[Properties.translate] !== undefined) {
495
- animation.target.translateX = animation.value[Properties.translate].x;
496
- animation.target.translateY = animation.value[Properties.translate].y;
501
+ if (animationInfo.propertyName === _transform) {
502
+ if (animationInfo.value[Properties.translate] !== undefined) {
503
+ animationInfo.target.translateX = animationInfo.value[Properties.translate].x;
504
+ animationInfo.target.translateY = animationInfo.value[Properties.translate].y;
497
505
  }
498
- if (animation.value[Properties.rotate] !== undefined) {
499
- animation.target.rotateX = animation.value[Properties.rotate].x;
500
- animation.target.rotateY = animation.value[Properties.rotate].y;
501
- animation.target.rotate = animation.value[Properties.rotate].z;
506
+ if (animationInfo.value[Properties.rotate] !== undefined) {
507
+ animationInfo.target.rotateX = animationInfo.value[Properties.rotate].x;
508
+ animationInfo.target.rotateY = animationInfo.value[Properties.rotate].y;
509
+ animationInfo.target.rotate = animationInfo.value[Properties.rotate].z;
502
510
  }
503
- if (animation.value[Properties.scale] !== undefined) {
504
- animation.target.scaleX = animation.value[Properties.scale].x;
505
- animation.target.scaleY = animation.value[Properties.scale].y;
511
+ if (animationInfo.value[Properties.scale] !== undefined) {
512
+ animationInfo.target.scaleX = animationInfo.value[Properties.scale].x;
513
+ animationInfo.target.scaleY = animationInfo.value[Properties.scale].y;
506
514
  }
507
515
  }
508
516
  }
509
517
  else {
510
- if (animation._propertyResetCallback) {
511
- animation._propertyResetCallback(animation._originalValue);
518
+ if (animationInfo._propertyResetCallback) {
519
+ animationInfo._propertyResetCallback(animationInfo._originalValue);
512
520
  }
513
521
  }
514
- if (finishedCallback) {
515
- const cancelled = !animationDidFinish;
516
- finishedCallback(cancelled);
517
- }
518
- if (animationDidFinish && nextAnimation) {
522
+ const cancelled = !animationDidFinish;
523
+ this.animationFinishedCallback(cancelled);
524
+ if (animationDidFinish && nextAnimation && !this._wasCancelled) {
519
525
  nextAnimation();
520
526
  }
521
- });
527
+ };
528
+ if (this.usePropertyAnimator) {
529
+ const finishCallback = (position) => finish(position === 0 /* End */);
530
+ if (isSpring) {
531
+ const animator = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(args.duration, 0.2, null);
532
+ animator.manualHitTestingEnabled = true;
533
+ animator.addAnimations(animate);
534
+ animator.addCompletion(finishCallback);
535
+ // for seems to be the only way to use a timeout. It is not too bad but would be better to be handled natively
536
+ // for this example this breaks slow animations in debugger
537
+ if (args.delay) {
538
+ setTimeout(() => {
539
+ animator.startAnimation();
540
+ }, args.delay * 1000);
541
+ }
542
+ else {
543
+ animator.startAnimation();
544
+ }
545
+ }
546
+ else {
547
+ CATransaction.begin();
548
+ CATransaction.setAnimationTimingFunction(animationInfo.curve);
549
+ UIViewPropertyAnimator.runningPropertyAnimatorWithDurationDelayOptionsAnimationsCompletion(args.duration, args.delay, animationOptions, animate, finishCallback);
550
+ CATransaction.commit();
551
+ }
552
+ }
553
+ else {
554
+ if (isSpring) {
555
+ UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(args.duration, delay, 0.2, 0, 196608 /* CurveLinear */ | animationOptions, animate, finish);
556
+ }
557
+ else {
558
+ CATransaction.begin();
559
+ CATransaction.setAnimationTimingFunction(animationInfo.curve);
560
+ UIView.animateWithDurationDelayOptionsAnimationsCompletion(args.duration, delay, animationOptions, animate, finish);
561
+ CATransaction.commit();
562
+ }
563
+ }
522
564
  }
523
565
  static _createNativeAffineTransform(animation) {
524
566
  const value = animation.value;
@@ -529,17 +571,28 @@ export class Animation extends AnimationBase {
529
571
  result = CATransform3DTranslate(result, x, y, 0);
530
572
  }
531
573
  if (value[Properties.scale] !== undefined) {
532
- const x = value[Properties.scale].x;
533
- const y = value[Properties.scale].y;
534
- result = CATransform3DScale(result, x === 0 ? 0.001 : x, y === 0 ? 0.001 : y, 1);
574
+ const x = value[Properties.scale].x || 1e-6;
575
+ const y = value[Properties.scale].y || 1e-6;
576
+ result = CATransform3DScale(result, x, y, 1);
577
+ }
578
+ if (value[Properties.rotate] !== undefined) {
579
+ const x = value[Properties.rotate].x;
580
+ const y = value[Properties.rotate].y;
581
+ const z = value[Properties.rotate].z;
582
+ const perspective = animation.target.perspective || 300;
583
+ // Only set perspective if there is 3D rotation
584
+ if (x || y) {
585
+ result.m34 = -1 / perspective;
586
+ }
587
+ result = iOSNativeHelper.applyRotateTransform(result, x, y, z);
535
588
  }
536
589
  return result;
537
590
  }
538
591
  static _isAffineTransform(property) {
539
- return property === _transform || property === Properties.translate || property === Properties.scale;
592
+ return property === _transform || property === Properties.translate || property === Properties.rotate || property === Properties.scale;
540
593
  }
541
594
  static _canBeMerged(animation1, animation2) {
542
- const result = Animation._isAffineTransform(animation1.property) && Animation._isAffineTransform(animation2.property) && animation1.target === animation2.target && animation1.duration === animation2.duration && animation1.delay === animation2.delay && animation1.iterations === animation2.iterations && animation1.curve === animation2.curve;
595
+ const result = Animation._isAffineTransform(animation1.propertyName) && Animation._isAffineTransform(animation2.propertyName) && animation1.target === animation2.target && animation1.duration === animation2.duration && animation1.delay === animation2.delay && animation1.iterations === animation2.iterations && animation1.curve === animation2.curve;
543
596
  return result;
544
597
  }
545
598
  static _mergeAffineTransformAnimations(propertyAnimations) {
@@ -551,7 +604,7 @@ export class Animation extends AnimationBase {
551
604
  if (propertyAnimations[i][_skip]) {
552
605
  continue;
553
606
  }
554
- if (!Animation._isAffineTransform(propertyAnimations[i].property)) {
607
+ if (!Animation._isAffineTransform(propertyAnimations[i].propertyName)) {
555
608
  // This is not an affine transform animation, so there is nothing to merge.
556
609
  result.push(propertyAnimations[i]);
557
610
  }
@@ -565,7 +618,8 @@ export class Animation extends AnimationBase {
565
618
  // }
566
619
  const newTransformAnimation = {
567
620
  target: propertyAnimations[i].target,
568
- property: _transform,
621
+ propertyName: _transform,
622
+ property: null,
569
623
  value: {},
570
624
  duration: propertyAnimations[i].duration,
571
625
  delay: propertyAnimations[i].delay,
@@ -575,7 +629,7 @@ export class Animation extends AnimationBase {
575
629
  if (Trace.isEnabled()) {
576
630
  Trace.write('Curve: ' + propertyAnimations[i].curve, Trace.categories.Animation);
577
631
  }
578
- newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value;
632
+ newTransformAnimation.value[propertyAnimations[i].propertyName] = propertyAnimations[i].value;
579
633
  if (Trace.isEnabled()) {
580
634
  Trace.write('Created new transform animation: ' + Animation._getAnimationInfo(newTransformAnimation), Trace.categories.Animation);
581
635
  }
@@ -587,7 +641,7 @@ export class Animation extends AnimationBase {
587
641
  if (Trace.isEnabled()) {
588
642
  Trace.write('Merging animations: ' + Animation._getAnimationInfo(newTransformAnimation) + ' + ' + Animation._getAnimationInfo(propertyAnimations[j]) + ';', Trace.categories.Animation);
589
643
  }
590
- newTransformAnimation.value[propertyAnimations[j].property] = propertyAnimations[j].value;
644
+ newTransformAnimation.value[propertyAnimations[j].propertyName] = propertyAnimations[j].value;
591
645
  // Mark that it has been merged so we can skip it on our outer loop.
592
646
  propertyAnimations[j][_skip] = true;
593
647
  }