@maccesar/titools 5.2.5 → 5.4.0

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 (138) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +58 -97
  3. package/agents/ti-pro.md +4 -2
  4. package/commands/ti-audit.md +7 -5
  5. package/docs/examples.md +24 -13
  6. package/docs/knowledge-index.md +2 -1
  7. package/lib/config.js +1 -0
  8. package/package.json +1 -1
  9. package/skills/alloy-guides/SKILL.md +18 -179
  10. package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
  11. package/skills/alloy-guides/references/CONCEPTS.md +27 -162
  12. package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
  13. package/skills/alloy-guides/references/MODELS.md +47 -723
  14. package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
  15. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
  16. package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
  17. package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
  18. package/skills/alloy-guides/references/WIDGETS.md +49 -127
  19. package/skills/alloy-howtos/SKILL.md +14 -169
  20. package/skills/alloy-howtos/references/best_practices.md +9 -113
  21. package/skills/alloy-howtos/references/cli_reference.md +18 -223
  22. package/skills/alloy-howtos/references/config_files.md +50 -133
  23. package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
  24. package/skills/alloy-howtos/references/samples.md +21 -138
  25. package/skills/ti-api/SKILL.md +10 -2
  26. package/skills/ti-api/references/api-android.md +36 -2
  27. package/skills/ti-api/references/api-app-platform.md +39 -3
  28. package/skills/ti-api/references/api-core.md +50 -18
  29. package/skills/ti-api/references/api-data-network.md +49 -35
  30. package/skills/ti-api/references/api-media.md +45 -27
  31. package/skills/ti-api/references/api-services.md +39 -9
  32. package/skills/ti-api/references/api-ui-android.md +33 -13
  33. package/skills/ti-api/references/api-ui-extras.md +41 -15
  34. package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
  35. package/skills/ti-api/references/api-ui-ios.md +74 -2
  36. package/skills/ti-api/references/api-ui-lists.md +32 -16
  37. package/skills/ti-api/references/api-ui-text-input.md +34 -17
  38. package/skills/ti-api/references/api-ui-views.md +27 -1
  39. package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
  40. package/skills/ti-api/references/api-xml-global.md +66 -16
  41. package/skills/ti-create-release/SKILL.md +98 -0
  42. package/skills/ti-create-release/references/module-discovery.md +69 -0
  43. package/skills/ti-expert/references/adaptive-layouts.md +1 -1
  44. package/skills/ti-guides/SKILL.md +37 -76
  45. package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
  46. package/skills/ti-guides/references/android-manifest.md +24 -83
  47. package/skills/ti-guides/references/app-distribution.md +31 -377
  48. package/skills/ti-guides/references/application-frameworks.md +127 -335
  49. package/skills/ti-guides/references/cli-reference.md +184 -633
  50. package/skills/ti-guides/references/commonjs-advanced.md +81 -231
  51. package/skills/ti-guides/references/compatibility-matrix.md +36 -75
  52. package/skills/ti-guides/references/hello-world.md +95 -70
  53. package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
  54. package/skills/ti-guides/references/resources.md +174 -142
  55. package/skills/ti-guides/references/sdk-release-notes.md +28 -71
  56. package/skills/ti-guides/references/tiapp-config.md +222 -598
  57. package/skills/ti-howtos/SKILL.md +23 -123
  58. package/skills/ti-howtos/references/cross-platform-development.md +119 -324
  59. package/skills/ti-howtos/references/debugging-profiling.md +77 -445
  60. package/skills/ti-howtos/references/extending-titanium.md +199 -673
  61. package/skills/ti-howtos/references/local-data-sources.md +87 -300
  62. package/skills/ti-howtos/references/location-and-maps.md +86 -213
  63. package/skills/ti-howtos/references/media-apis.md +103 -223
  64. package/skills/ti-howtos/references/notification-services.md +86 -506
  65. package/skills/ti-howtos/references/remote-data-sources.md +97 -316
  66. package/skills/ti-howtos/references/using-modules.md +77 -133
  67. package/skills/ti-synthengine/SKILL.md +62 -111
  68. package/skills/ti-synthengine/assets/example/README.md +50 -59
  69. package/skills/ti-synthengine/assets/example/app.js +67 -65
  70. package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
  71. package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
  72. package/skills/ti-synthengine/assets/index.d.ts +122 -2
  73. package/skills/ti-synthengine/references/advanced-examples.md +4 -4
  74. package/skills/ti-synthengine/references/api.md +40 -18
  75. package/skills/ti-synthengine/references/audio-engine.md +15 -57
  76. package/skills/ti-synthengine/references/examples.md +63 -6
  77. package/skills/ti-synthengine/references/guide.md +61 -57
  78. package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
  79. package/skills/ti-synthengine/references/native-variation.md +53 -14
  80. package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
  81. package/skills/ti-synthengine/references/recipes.md +19 -16
  82. package/skills/ti-synthengine/references/recommendations.md +12 -12
  83. package/skills/ti-synthengine/references/sound-api.md +197 -0
  84. package/skills/ti-synthengine/references/sound-design.md +7 -7
  85. package/skills/ti-synthengine/references/source-notes.md +62 -172
  86. package/skills/ti-synthengine/references/troubleshooting.md +17 -19
  87. package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
  88. package/skills/ti-ui/SKILL.md +28 -143
  89. package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
  90. package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
  91. package/skills/ti-ui/references/listviews-and-performance.md +100 -703
  92. package/skills/ti-ui/references/platform-conventions.md +180 -0
  93. package/skills/ti-ui/references/user-interface.md +43 -0
  94. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  95. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  96. package/skills/ti-guides/references/coding-best-practices.md +0 -149
  97. package/skills/ti-guides/references/javascript-primer.md +0 -414
  98. package/skills/ti-guides/references/reserved-words.md +0 -36
  99. package/skills/ti-guides/references/style-and-conventions.md +0 -103
  100. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
  101. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  102. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  103. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  104. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  105. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
  106. package/skills/ti-howtos/references/tutorials.md +0 -565
  107. package/skills/ti-howtos/references/web-content-integration.md +0 -287
  108. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
  109. package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
  110. package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
  111. package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
  112. package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
  113. package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
  114. package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
  115. package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
  116. package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
  117. package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
  118. package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
  119. package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
  120. package/skills/ti-synthengine/references/performance-review.json +0 -1146
  121. package/skills/ti-synthengine/references/physical-validation.json +0 -1457
  122. package/skills/ti-synthengine/references/source-snapshot.json +0 -542
  123. package/skills/ti-synthengine/references/stats-performance.json +0 -2992
  124. package/skills/ti-synthengine/references/stats-performance.md +0 -82
  125. package/skills/ti-synthengine/references/studio-validation.json +0 -6202
  126. package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
  127. package/skills/ti-synthengine/references/unified-validation.json +0 -314
  128. package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
  129. package/skills/ti-ui/references/animation-and-matrices.md +0 -569
  130. package/skills/ti-ui/references/application-structures.md +0 -626
  131. package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
  132. package/skills/ti-ui/references/event-handling.md +0 -401
  133. package/skills/ti-ui/references/gestures.md +0 -448
  134. package/skills/ti-ui/references/orientation.md +0 -374
  135. package/skills/ti-ui/references/platform-ui-android.md +0 -727
  136. package/skills/ti-ui/references/platform-ui-ios.md +0 -576
  137. package/skills/ti-ui/references/scrolling-views.md +0 -288
  138. package/skills/ti-ui/references/tableviews.md +0 -542
@@ -1,569 +0,0 @@
1
- # Animation, matrices, and transitions
2
-
3
- <!-- TOC-START -->
4
- ## Contents
5
-
6
- - [1. Overview](#1-overview)
7
- - [2. Basic animations](#2-basic-animations)
8
- - [3. 2D matrix animations](#3-2d-matrix-animations)
9
- - [4. 3D matrix animations (iOS only)](#4-3d-matrix-animations-ios-only)
10
- - [5. iOS transitions](#5-ios-transitions)
11
- - [6. Dynamic animations (iOS only)](#6-dynamic-animations-ios-only)
12
- - [7. Animation events](#7-animation-events)
13
- - [8. Common animation patterns](#8-common-animation-patterns)
14
- - [9. Performance considerations](#9-performance-considerations)
15
- - [10. Platform differences](#10-platform-differences)
16
- - [Best practices](#best-practices)
17
-
18
- <!-- TOC-END -->
19
-
20
- ## 1. Overview
21
-
22
- Animations make state changes easier to read and can help an interface feel responsive. Use them with restraint. Titanium includes:
23
- - Basic property animations (opacity, position, color, etc.)
24
- - 2D matrix transforms (scale, rotate, translate) for iOS and Android
25
- - 3D matrix transforms (x, y, z space) for iOS only
26
- - iOS transitions (flip, curl, etc.)
27
- - Dynamic, physics-based animations for iOS only
28
-
29
- ## 2. Basic animations
30
-
31
- ### Property animation syntax
32
-
33
- ```javascript
34
- // Method 1: Direct object
35
- view.animate({
36
- opacity: 0,
37
- duration: 2000
38
- });
39
-
40
- // Method 2: Animation object (reusable)
41
- const fadeOut = Ti.UI.createAnimation({
42
- opacity: 0,
43
- duration: 2000
44
- });
45
- view.animate(fadeOut);
46
-
47
- // Method 3: With callback
48
- view.animate({
49
- opacity: 0,
50
- duration: 2000
51
- }, () => {
52
- Ti.API.info('Animation complete');
53
- // Optional: reverse animation
54
- view.animate({
55
- opacity: 1,
56
- duration: 2000
57
- });
58
- });
59
- ```
60
-
61
- ### Animation properties
62
-
63
- | Property | Description | Default |
64
- | -------------------------------- | ------------------------- | ----------------------------------- |
65
- | `duration` | Duration in milliseconds | 0 |
66
- | `delay` | Delay before starting | 0 |
67
- | `curve` | Easing function | `Ti.UI.ANIMATION_CURVE_EASE_IN_OUT` |
68
- | `autoreverse` | Return to original state | `false` |
69
- | `repeat` | Number of times to repeat | 0 |
70
- | `opacity` | Target opacity (0-1) | - |
71
- | `top`, `left`, `bottom`, `right` | Position values | - |
72
- | `width`, `height` | Size values | - |
73
- | `backgroundColor` | Target color | - |
74
- | `transform` | Matrix transformation | - |
75
- | `view` | View for transition | - |
76
- | `transition` | Transition type (iOS) | - |
77
-
78
- ### Animation curves (easing)
79
-
80
- ```javascript
81
- // Available curves
82
- Ti.UI.ANIMATION_CURVE_EASE_IN_OUT
83
- Ti.UI.ANIMATION_CURVE_EASE_IN
84
- Ti.UI.ANIMATION_CURVE_EASE_OUT
85
- Ti.UI.ANIMATION_CURVE_LINEAR
86
- Ti.UI.ANIMATION_CURVE_SPRING // iOS only
87
-
88
- // Example
89
- view.animate({
90
- left: 100,
91
- duration: 1000,
92
- curve: Ti.UI.ANIMATION_CURVE_EASE_IN_OUT
93
- });
94
- ```
95
-
96
- ### Reversing animation
97
-
98
- ```javascript
99
- // Use autoreverse for simple reversal
100
- view.animate({
101
- opacity: 0,
102
- duration: 2000,
103
- autoreverse: true
104
- });
105
-
106
- // Or manual reversal with callback
107
- view.animate({
108
- opacity: 0,
109
- duration: 2000
110
- }, () => {
111
- view.animate({
112
- opacity: 1,
113
- duration: 2000
114
- });
115
- });
116
- ```
117
-
118
- ### Repeating animation
119
-
120
- ```javascript
121
- // Repeat 3 times
122
- view.animate({
123
- opacity: 0,
124
- duration: 500,
125
- repeat: 3
126
- });
127
-
128
- // Infinite loop (with autoreverse)
129
- view.animate({
130
- opacity: 0,
131
- duration: 500,
132
- autoreverse: true,
133
- repeat: Number.MAX_VALUE // Infinite
134
- });
135
-
136
- // Stop animation
137
- view.animate({ opacity: view.opacity, duration: 0 });
138
- ```
139
-
140
- ## 3. 2D matrix animations
141
-
142
- 2D matrices work on both iOS and Android. They transform the x and y plane with scale, rotate, translate, and skew.
143
-
144
- ### Basic 2D transform
145
-
146
- ```javascript
147
- // Create matrix
148
- let matrix2d = Ti.UI.create2DMatrix();
149
-
150
- // Apply transformations
151
- matrix2d = matrix2d.rotate(20); // Rotate 20 degrees
152
- matrix2d = matrix2d.scale(1.5); // Scale 1.5x
153
- matrix2d = matrix2d.translate(50, 50); // Move 50px right, 50px down
154
-
155
- // Apply animation
156
- view.animate({
157
- transform: matrix2d,
158
- duration: 2000,
159
- autoreverse: true,
160
- repeat: 3
161
- });
162
- ```
163
-
164
- ### 2D matrix methods
165
-
166
- | Method | Description |
167
- | ------------------- | ------------------------- |
168
- | `rotate(degrees)` | Rotate clockwise |
169
- | `scale(sx, sy)` | Scale (sy defaults to sx) |
170
- | `translate(dx, dy)` | Move by delta |
171
- | `skew(x, y)` | Skew or shear |
172
- | `invert()` | Invert matrix |
173
- | `multiply(matrix)` | Multiply matrices |
174
- | `length` | Get matrix length |
175
-
176
- ### Sequential transformations
177
-
178
- Order matters.
179
-
180
- ```javascript
181
- // Rotate THEN scale
182
- const matrix1 = Ti.UI.create2DMatrix()
183
- .rotate(45)
184
- .scale(2);
185
-
186
- // Scale THEN rotate (different result)
187
- const matrix2 = Ti.UI.create2DMatrix()
188
- .scale(2)
189
- .rotate(45);
190
- ```
191
-
192
- ### Identity (reset) transform
193
-
194
- ```javascript
195
- // Reset to original state
196
- const identity = Ti.UI.create2DMatrix();
197
- view.animate({
198
- transform: identity,
199
- duration: 500
200
- });
201
- ```
202
-
203
- ## 4. 3D matrix animations (iOS only)
204
-
205
- 3D matrices work in x, y, and z space on iOS only.
206
-
207
- ### Basic 3D transform
208
-
209
- ```javascript
210
- let matrix3d = Ti.UI.create3DMatrix();
211
-
212
- // Rotate around axis vector (x, y, z)
213
- matrix3d = matrix3d.rotate(180, 1, 1, 0); // 180 degrees around diagonal
214
-
215
- // Scale in 3 dimensions
216
- matrix3d = matrix3d.scale(2, 2, 2);
217
-
218
- // Apply animation
219
- view.animate({
220
- transform: matrix3d,
221
- duration: 2000,
222
- autoreverse: true
223
- });
224
- ```
225
-
226
- ### 3D matrix methods
227
-
228
- | Method | Description |
229
- | -------------------------- | -------------------- |
230
- | `rotate(degrees, x, y, z)` | Rotate around vector |
231
- | `scale(sx, sy, sz)` | Scale in 3D |
232
- | `translate(dx, dy, dz)` | Move in 3D |
233
- | `invert()` | Invert matrix |
234
- | `multiply(matrix)` | Multiply matrices |
235
- | `perspective(p)` | Set perspective |
236
-
237
- ### Flip card effect
238
-
239
- ```javascript
240
- const frontView = Ti.UI.createView({
241
- backgroundColor: 'red',
242
- width: 200, height: 200
243
- });
244
-
245
- const backView = Ti.UI.createView({
246
- backgroundColor: 'blue',
247
- width: 200, height: 200
248
- });
249
-
250
- let isFlipped = false;
251
-
252
- frontView.addEventListener('click', () => {
253
- const matrix = Ti.UI.create3DMatrix().rotate(180, 0, 1, 0);
254
-
255
- if (!isFlipped) {
256
- frontView.animate({
257
- transform: matrix,
258
- duration: 500,
259
- visible: false
260
- });
261
- backView.transform = matrix;
262
- backView.animate({
263
- transform: Ti.UI.create3DMatrix(),
264
- duration: 500,
265
- visible: true
266
- });
267
- }
268
- isFlipped = !isFlipped;
269
- });
270
- ```
271
-
272
- ## 5. iOS transitions
273
-
274
- Transitions are built-in animations for switching between views and windows.
275
-
276
- ### Transition constants
277
-
278
- ```javascript
279
- Ti.UI.iPhone.AnimationStyle.CURL_UP
280
- Ti.UI.iPhone.AnimationStyle.CURL_DOWN
281
- Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
282
- Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT
283
- Ti.UI.iPhone.AnimationStyle.NONE
284
- Ti.UI.iPhone.AnimationStyle.OPAQUE_FADE // Fade with black (not transparent)
285
- ```
286
-
287
- ### View transition
288
-
289
- ```javascript
290
- const container = Ti.UI.createView({ width: 300, height: 300 });
291
- const box1 = Ti.UI.createView({ backgroundColor: 'red' });
292
- const box2 = Ti.UI.createView({ backgroundColor: 'blue' });
293
- container.add(box1);
294
-
295
- let selectedIndex = 0;
296
-
297
- container.addEventListener('click', () => {
298
- if (selectedIndex % 2 === 0) {
299
- container.animate({
300
- view: box2,
301
- transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
302
- });
303
- } else {
304
- container.animate({
305
- view: box1,
306
- transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT
307
- });
308
- }
309
- selectedIndex++;
310
- });
311
- ```
312
-
313
- ### Window transition (NavigationWindow)
314
-
315
- ```javascript
316
- const navWindow = Ti.UI.createNavigationWindow({
317
- window: Ti.UI.createWindow({ backgroundColor: 'white' })
318
- });
319
-
320
- const win1 = Ti.UI.createWindow({
321
- title: 'Window 1',
322
- backgroundColor: 'red',
323
- transitionAnimation: Ti.UI.iOS.createTransitionAnimation({
324
- hide: Ti.UI.createAnimation({
325
- transform: Ti.UI.create3DMatrix().translate(-300, 0, 0),
326
- duration: 500
327
- }),
328
- show: Ti.UI.createAnimation({
329
- transform: Ti.UI.create3DMatrix(),
330
- duration: 500
331
- })
332
- })
333
- });
334
-
335
- navWindow.openWindow(win1);
336
- ```
337
-
338
- ## 6. Dynamic animations (iOS only)
339
-
340
- Physics-based animations use `Ti.UI.iOS.Animator`.
341
-
342
- ### Gravity animation
343
-
344
- ```javascript
345
- const animator = Ti.UI.iOS.createAnimator({
346
- referenceView: containerView
347
- });
348
-
349
- // Add gravity behavior
350
- const gravity = Ti.UI.iOS.createGravityBehavior({
351
- gravityDirection: { x: 0.0, y: 1.0 } // Downward
352
- });
353
-
354
- // Add items to gravity
355
- gravity.addItem(animatedView);
356
- animator.addBehavior(gravity);
357
-
358
- // Add collision boundaries
359
- const collision = Ti.UI.iOS.createCollisionBehavior({
360
- collisionMode: Ti.UI.iOS.COLLISION_MODE_BOUNDARY,
361
- boundary: containerView.toImage()
362
- });
363
- collision.addItem(animatedView);
364
- animator.addBehavior(collision);
365
-
366
- animator.startAnimator();
367
- ```
368
-
369
- ### Attachment (spring) behavior
370
-
371
- ```javascript
372
- const attachment = Ti.UI.iOS.createAttachmentBehavior({
373
- items: [view1, view2],
374
- anchorPoint: { x: 150, y: 150 },
375
- frequency: 1.0, // Oscillations per second
376
- damping: 0.1, // Bounciness (0 = none, 1 = no bounce)
377
- length: 100 // Distance between items
378
- });
379
-
380
- animator.addBehavior(attachment);
381
- animator.startAnimator();
382
- ```
383
-
384
- ### Push behavior
385
-
386
- ```javascript
387
- const push = Ti.UI.iOS.createPushBehavior({
388
- pushDirection: { x: 1.0, y: 0.0 }, // Rightward
389
- mode: Ti.UI.iOS.PUSH_MODE_INSTANTANEOUS,
390
- pushMagnitude: 5.0
391
- });
392
-
393
- push.addItem(viewToPush);
394
- animator.addBehavior(push);
395
- ```
396
-
397
- ## 7. Animation events
398
-
399
- ### Animation lifecycle
400
-
401
- ```javascript
402
- const animation = Ti.UI.createAnimation({
403
- opacity: 0,
404
- duration: 2000
405
- });
406
-
407
- // 'start' event
408
- animation.addEventListener('start', (e) => {
409
- Ti.API.info('Animation started');
410
- });
411
-
412
- // 'complete' event
413
- animation.addEventListener('complete', (e) => {
414
- Ti.API.info(`Animation complete. Was canceled: ${e.cancelled}`);
415
- });
416
-
417
- view.animate(animation);
418
- ```
419
-
420
- ### Stopping animations
421
-
422
- ```javascript
423
- // Method 1: Overwrite with new animation (duration: 0)
424
- view.animate({
425
- opacity: view.opacity,
426
- duration: 0,
427
- curve: Ti.UI.ANIMATION_CURVE_LINEAR
428
- });
429
-
430
- // Method 2: Remove from parent
431
- parent.remove(view);
432
-
433
- // Method 3: Set visible to false
434
- view.visible = false;
435
- ```
436
-
437
- ## 8. Common animation patterns
438
-
439
- ### Fade in and out
440
-
441
- ```javascript
442
- function fadeIn(view, duration, callback) {
443
- view.opacity = 0;
444
- view.animate({ opacity: 1, duration: duration }, callback);
445
- }
446
-
447
- function fadeOut(view, duration, callback) {
448
- view.animate({ opacity: 0, duration: duration }, function() {
449
- view.visible = false;
450
- if (callback) callback();
451
- });
452
- }
453
- ```
454
-
455
- ### Slide in
456
-
457
- ```javascript
458
- function slideInFromRight(view, duration) {
459
- view.left = Ti.Platform.displayCaps.platformWidth; // Start off-screen
460
- view.animate({
461
- left: 0,
462
- duration: duration,
463
- curve: Ti.UI.ANIMATION_CURVE_EASE_OUT
464
- });
465
- }
466
- ```
467
-
468
- ### Pulse animation
469
-
470
- ```javascript
471
- function pulse(view) {
472
- view.animate({
473
- transform: Ti.UI.create2DMatrix().scale(1.1),
474
- duration: 150,
475
- autoreverse: true,
476
- curve: Ti.UI.ANIMATION_CURVE_EASE_IN_OUT
477
- }, function() {
478
- // Optional: repeat
479
- // pulse(view);
480
- });
481
- }
482
- ```
483
-
484
- ### Shake animation
485
-
486
- ```javascript
487
- function shake(view) {
488
- const shake = Ti.UI.createAnimation({
489
- transform: Ti.UI.create2DMatrix().translate(10, 0),
490
- duration: 50,
491
- autoreverse: true,
492
- repeat: 5
493
- });
494
- view.animate(shake);
495
- }
496
- ```
497
-
498
- ### Bounce in
499
-
500
- ```javascript
501
- function bounceIn(view) {
502
- view.transform = Ti.UI.create2DMatrix().scale(0);
503
- view.animate({
504
- transform: Ti.UI.create2DMatrix().scale(1.2),
505
- duration: 300,
506
- curve: Ti.UI.ANIMATION_CURVE_EASE_OUT
507
- }, function() {
508
- view.animate({
509
- transform: Ti.UI.create2DMatrix().scale(1.0),
510
- duration: 200,
511
- curve: Ti.UI.ANIMATION_CURVE_EASE_IN_OUT
512
- });
513
- });
514
- }
515
- ```
516
-
517
- ## 9. Performance considerations
518
-
519
- Do:
520
- - Use hardware-accelerated properties (opacity, transform).
521
- - Animate `transform` instead of `top` or `left` when possible.
522
- - Use `autoreverse` for simple back-and-forth.
523
- - Cache animation objects for reuse.
524
- - Stop unused animations.
525
-
526
- Don't:
527
- - Animate `width` or `height` since it triggers layout recalculation.
528
- - Animate too many views at once.
529
- - Use JavaScript loops for animation.
530
- - Animate properties that trigger reflow.
531
-
532
- ### Bad vs good
533
-
534
- ```javascript
535
- // BAD - Triggers layout
536
- view.animate({
537
- left: view.left + 100,
538
- top: view.top + 100,
539
- duration: 500
540
- });
541
-
542
- // GOOD - Hardware accelerated
543
- view.animate({
544
- transform: Ti.UI.create2DMatrix().translate(100, 100),
545
- duration: 500
546
- });
547
- ```
548
-
549
- ## 10. Platform differences
550
-
551
- ### iOS vs Android
552
-
553
- | Feature | iOS | Android |
554
- | ------------------ | ------------ | ----------------- |
555
- | 2D matrix | Full support | Full support |
556
- | 3D matrix | Full support | Not supported |
557
- | Transitions | Full support | Not supported |
558
- | Dynamic animations | Full support | Not supported |
559
- | Curves | +SPRING | Basic curves only |
560
- | Color animation | RGBA full | Basic colors |
561
-
562
- ## Best practices
563
-
564
- 1. Keep animations simple. The more complex they get, the harder they are to debug.
565
- 2. Test on devices. Simulator performance is not the same.
566
- 3. Consider accessibility. Respect the `reduceMotion` setting.
567
- 4. Use sensible duration. 200 to 300 ms for subtle motion, about 500 ms for noticeable.
568
- 5. Avoid long animation chains. Prefer a callback instead of deep nesting.
569
- 6. Clean up. Remove event listeners on animation completion.