| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5129516 commit 2275d3d
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ import enums = require("ui/enums"); | |||
| 8 | 8 | import styleModule = require("ui/styling/style"); | |
| 9 | 9 | import lazy from "utils/lazy"; | |
| 10 | 10 | import { CacheLayerType } from "utils/utils"; | |
| 11 | + import dependencyObservable = require("ui/core/dependency-observable"); | ||
| 11 | 12 | ||
| 12 | 13 | global.moduleMerge(common, exports); | |
| 13 | 14 | ||
@@ -75,7 +76,7 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 75 | 76 | this._animatorSet.start(); | |
| 76 | 77 | return animationFinishedPromise; | |
| 77 | 78 | } | |
| 78 | - | ||
| 79 | + | ||
| 79 | 80 | public cancel(): void { | |
| 80 | 81 | super.cancel(); | |
| 81 | 82 | if (trace.enabled) { | |
@@ -188,29 +189,26 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 188 | 189 | } | |
| 189 | 190 | } | |
| 190 | 191 | ||
| 191 | - let valueSource = this._valueSource; | ||
| 192 | + let valueSource = this._valueSource !== undefined ? this._valueSource : dependencyObservable.ValueSource.Local; | ||
| 192 | 193 | ||
| 193 | 194 | switch (propertyAnimation.property) { | |
| 194 | 195 | ||
| 195 | 196 | case common.Properties.opacity: | |
| 196 | 197 | originalValue1 = nativeView.getAlpha(); | |
| 197 | 198 | nativeArray = (<any>Array).create("float", 1); | |
| 198 | 199 | nativeArray[0] = propertyAnimation.value; | |
| 199 | - if (this._valueSource !== undefined) { | ||
| 200 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 201 | - propertyAnimation.target.style._setValue(styleModule.opacityProperty, propertyAnimation.value, valueSource); | ||
| 202 | - })); | ||
| 203 | - } | ||
| 204 | - else { | ||
| 205 | - propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value; })); | ||
| 206 | - } | ||
| 207 | - propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue1); })); | ||
| 200 | + propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 201 | + propertyAnimation.target.style._setValue(styleModule.opacityProperty, propertyAnimation.value, valueSource); | ||
| 202 | + })); | ||
| 203 | + propertyResetCallbacks.push(checkAnimation(() => { | ||
| 204 | + propertyAnimation.target.style._setValue(styleModule.opacityProperty, originalValue1, valueSource); | ||
| 205 | + })); | ||
| 208 | 206 | animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray)); | |
| 209 | 207 | break; | |
| 210 | 208 | ||
| 211 | 209 | case common.Properties.backgroundColor: | |
| 212 | 210 | ensureArgbEvaluator(); | |
| 213 | - originalValue1 = nativeView.getBackground(); | ||
| 211 | + originalValue1 = propertyAnimation.target.backgroundColor; | ||
| 214 | 212 | nativeArray = (<any>Array).create(java.lang.Object, 2); | |
| 215 | 213 | nativeArray[0] = propertyAnimation.target.backgroundColor ? java.lang.Integer.valueOf((<color.Color>propertyAnimation.target.backgroundColor).argb) : java.lang.Integer.valueOf(-1); | |
| 216 | 214 | nativeArray[1] = java.lang.Integer.valueOf((<color.Color>propertyAnimation.value).argb); | |
@@ -222,16 +220,12 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 222 | 220 | } | |
| 223 | 221 | })); | |
| 224 | 222 | ||
| 225 | - if (this._valueSource !== undefined) { | ||
| 226 | - let valueSource = this._valueSource; | ||
| 227 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 228 | - propertyAnimation.target.style._setValue(styleModule.backgroundColorProperty, propertyAnimation.value, valueSource); | ||
| 229 | - })); | ||
| 230 | - } | ||
| 231 | - else { | ||
| 232 | - propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.backgroundColor = propertyAnimation.value; })); | ||
| 233 | - } | ||
| 234 | - propertyResetCallbacks.push(checkAnimation(() => { nativeView.setBackground(originalValue1); })); | ||
| 223 | + propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 224 | + propertyAnimation.target.style._setValue(styleModule.backgroundColorProperty, propertyAnimation.value, valueSource); | ||
| 225 | + })); | ||
| 226 | + propertyResetCallbacks.push(checkAnimation(() => { | ||
| 227 | + propertyAnimation.target.style._setValue(styleModule.backgroundColorProperty, originalValue1, valueSource); | ||
| 228 | + })); | ||
| 235 | 229 | animators.push(animator); | |
| 236 | 230 | break; | |
| 237 | 231 | ||
@@ -251,22 +245,14 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 251 | 245 | originalValue1 = nativeView.getTranslationX(); | |
| 252 | 246 | originalValue2 = nativeView.getTranslationY(); | |
| 253 | 247 | ||
| 254 | - if (this._valueSource !== undefined) { | ||
| 255 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 256 | - propertyAnimation.target.style._setValue(styleModule.translateXProperty, propertyAnimation.value.x, valueSource); | ||
| 257 | - propertyAnimation.target.style._setValue(styleModule.translateYProperty, propertyAnimation.value.y, valueSource); | ||
| 258 | - })); | ||
| 259 | - } | ||
| 260 | - else { | ||
| 261 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 262 | - propertyAnimation.target.translateX = propertyAnimation.value.x; | ||
| 263 | - propertyAnimation.target.translateY = propertyAnimation.value.y; | ||
| 264 | - })); | ||
| 265 | - } | ||
| 248 | + propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 249 | + propertyAnimation.target.style._setValue(styleModule.translateXProperty, propertyAnimation.value.x, valueSource); | ||
| 250 | + propertyAnimation.target.style._setValue(styleModule.translateYProperty, propertyAnimation.value.y, valueSource); | ||
| 251 | + })); | ||
| 266 | 252 | ||
| 267 | 253 | propertyResetCallbacks.push(checkAnimation(() => { | |
| 268 | - nativeView.setTranslationX(originalValue1); | ||
| 269 | - nativeView.setTranslationY(originalValue2); | ||
| 254 | + propertyAnimation.target.style._setValue(styleModule.translateXProperty, originalValue1, valueSource); | ||
| 255 | + propertyAnimation.target.style._setValue(styleModule.translateYProperty, originalValue2, valueSource); | ||
| 270 | 256 | })); | |
| 271 | 257 | ||
| 272 | 258 | animatorSet = new android.animation.AnimatorSet(); | |
@@ -291,22 +277,14 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 291 | 277 | originalValue1 = nativeView.getScaleX(); | |
| 292 | 278 | originalValue2 = nativeView.getScaleY(); | |
| 293 | 279 | ||
| 294 | - if (this._valueSource !== undefined) { | ||
| 295 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 296 | - propertyAnimation.target.style._setValue(styleModule.scaleXProperty, propertyAnimation.value.x, valueSource); | ||
| 297 | - propertyAnimation.target.style._setValue(styleModule.scaleYProperty, propertyAnimation.value.y, valueSource); | ||
| 298 | - })); | ||
| 299 | - } | ||
| 300 | - else { | ||
| 301 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 302 | - propertyAnimation.target.scaleX = propertyAnimation.value.x; | ||
| 303 | - propertyAnimation.target.scaleY = propertyAnimation.value.y; | ||
| 304 | - })); | ||
| 305 | - } | ||
| 280 | + propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 281 | + propertyAnimation.target.style._setValue(styleModule.scaleXProperty, propertyAnimation.value.x, valueSource); | ||
| 282 | + propertyAnimation.target.style._setValue(styleModule.scaleYProperty, propertyAnimation.value.y, valueSource); | ||
| 283 | + })); | ||
| 306 | 284 | ||
| 307 | 285 | propertyResetCallbacks.push(checkAnimation(() => { | |
| 308 | - nativeView.setScaleY(originalValue1); | ||
| 309 | - nativeView.setScaleY(originalValue2); | ||
| 286 | + propertyAnimation.target.style._setValue(styleModule.scaleXProperty, originalValue1, valueSource); | ||
| 287 | + propertyAnimation.target.style._setValue(styleModule.scaleYProperty, originalValue2, valueSource); | ||
| 310 | 288 | })); | |
| 311 | 289 | ||
| 312 | 290 | animatorSet = new android.animation.AnimatorSet(); | |
@@ -319,15 +297,12 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 319 | 297 | originalValue1 = nativeView.getRotation(); | |
| 320 | 298 | nativeArray = (<any>Array).create("float", 1); | |
| 321 | 299 | nativeArray[0] = propertyAnimation.value; | |
| 322 | - if (this._valueSource !== undefined) { | ||
| 323 | - propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 324 | - propertyAnimation.target.style._setValue(styleModule.rotateProperty, propertyAnimation.value, valueSource); | ||
| 325 | - })); | ||
| 326 | - } | ||
| 327 | - else { | ||
| 328 | - propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.rotate = propertyAnimation.value; })); | ||
| 329 | - } | ||
| 330 | - propertyResetCallbacks.push(checkAnimation(() => { nativeView.setRotation(originalValue1); })); | ||
| 300 | + propertyUpdateCallbacks.push(checkAnimation(() => { | ||
| 301 | + propertyAnimation.target.style._setValue(styleModule.rotateProperty, propertyAnimation.value, valueSource); | ||
| 302 | + })); | ||
| 303 | + propertyResetCallbacks.push(checkAnimation(() => { | ||
| 304 | + propertyAnimation.target.style._setValue(styleModule.rotateProperty, originalValue1, valueSource); | ||
| 305 | + })); | ||
| 331 | 306 | animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "rotation", nativeArray)); | |
| 332 | 307 | break; | |
| 333 | 308 | ||
@@ -358,7 +333,7 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 358 | 333 | if (propertyAnimation.curve !== undefined) { | |
| 359 | 334 | animators[i].setInterpolator(propertyAnimation.curve); | |
| 360 | 335 | } | |
| 361 | - | ||
| 336 | + | ||
| 362 | 337 | if (trace.enabled) { | |
| 363 | 338 | trace.write("Animator created: " + animators[i], trace.categories.Animation); | |
| 364 | 339 | } | |
@@ -372,7 +347,7 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 372 | 347 | private static _getAndroidRepeatCount(iterations: number): number { | |
| 373 | 348 | return (iterations === Number.POSITIVE_INFINITY) ? android.view.animation.Animation.INFINITE : iterations - 1; | |
| 374 | 349 | } | |
| 375 | - | ||
| 350 | + | ||
| 376 | 351 | private _enableHardwareAcceleration() { | |
| 377 | 352 | for (let i = 0, length = this._propertyAnimations.length; i < length; i++) { | |
| 378 | 353 | let cache = <CacheLayerType>this._propertyAnimations[i].target._nativeView; | |
@@ -381,7 +356,7 @@ export class Animation extends common.Animation implements definition.Animation | |||
| 381 | 356 | if (layerType !== android.view.View.LAYER_TYPE_HARDWARE) { | |
| 382 | 357 | cache.layerType = layerType; | |
| 383 | 358 | cache.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null); | |
| 384 | - } | ||
| 359 | + } | ||
| 385 | 360 | } | |
| 386 | 361 | } | |
| 387 | 362 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments