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