mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed: Visual states not working properly when the animation is canceled in Android
This commit is contained in:
@@ -9,6 +9,7 @@ import enums = require("ui/enums");
|
||||
import utils = require("utils/utils");
|
||||
import color = require("color");
|
||||
import observable = require("data/observable");
|
||||
import keyframeAnimationModule = require("ui/animation/keyframe-animation");
|
||||
import {PropertyMetadata, ProxyObject} from "ui/core/proxy";
|
||||
import {PropertyMetadataSettings, PropertyChangeData, Property, ValueSource, PropertyMetadata as doPropertyMetadata} from "ui/core/dependency-observable";
|
||||
import {registerSpecialProperty} from "ui/builder/special-properties";
|
||||
@@ -174,6 +175,8 @@ export class View extends ProxyObject implements definition.View {
|
||||
private _isLoaded: boolean;
|
||||
private _isLayoutValid: boolean = false;
|
||||
|
||||
private _registeredAnimations: Array<keyframeAnimationModule.KeyframeAnimation>;
|
||||
|
||||
public _domId: number;
|
||||
public _isAddedToNativeVisualTree = false;
|
||||
|
||||
@@ -1170,12 +1173,36 @@ export class View extends ProxyObject implements definition.View {
|
||||
}
|
||||
|
||||
public createAnimation(animation: any): any {
|
||||
var animationModule: typeof animModule = require("ui/animation");
|
||||
var that = this;
|
||||
let animationModule: typeof animModule = require("ui/animation");
|
||||
let that = this;
|
||||
animation.target = that;
|
||||
return new animationModule.Animation([animation]);
|
||||
}
|
||||
|
||||
public _registerAnimation(animation: keyframeAnimationModule.KeyframeAnimation) {
|
||||
if (this._registeredAnimations === undefined) {
|
||||
this._registeredAnimations = new Array<keyframeAnimationModule.KeyframeAnimation>();
|
||||
}
|
||||
this._registeredAnimations.push(animation);
|
||||
}
|
||||
|
||||
public _unregisterAnimation(animation: keyframeAnimationModule.KeyframeAnimation) {
|
||||
if (this._registeredAnimations) {
|
||||
let index = this._registeredAnimations.indexOf(animation);
|
||||
if (index >= 0) {
|
||||
this._registeredAnimations.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public _unregisterAllAnimations() {
|
||||
if (this._registeredAnimations) {
|
||||
for (let animation of this._registeredAnimations) {
|
||||
animation.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
var str = this.typeName;
|
||||
if (this.id) {
|
||||
|
||||
5
ui/core/view.d.ts
vendored
5
ui/core/view.d.ts
vendored
@@ -6,6 +6,7 @@ declare module "ui/core/view" {
|
||||
import color = require("color");
|
||||
import observable = require("data/observable");
|
||||
import animation = require("ui/animation");
|
||||
import keyframeAnimationModule = require("ui/animation/keyframe-animation");
|
||||
|
||||
/**
|
||||
* Gets a child view by id.
|
||||
@@ -574,6 +575,10 @@ declare module "ui/core/view" {
|
||||
_domId: number;
|
||||
_cssClasses: Array<string>;
|
||||
|
||||
_registerAnimation(animation: keyframeAnimationModule.KeyframeAnimation);
|
||||
_unregisterAnimation(animation: keyframeAnimationModule.KeyframeAnimation);
|
||||
_unregisterAllAnimations();
|
||||
|
||||
_isAddedToNativeVisualTree: boolean;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user