feat: add API clearAnimation

This commit is contained in:
pengfei.zhou
2021-04-21 18:59:29 +08:00
committed by osborn
parent 93293b099f
commit 5c20680c4c
12 changed files with 155 additions and 26 deletions

View File

@@ -1380,6 +1380,7 @@ var Animation = /** @class */ (function () {
this.changeables = new Map;
this.duration = 0;
this.fillMode = exports.FillMode.Forward;
this.id = uniqueId("Animation");
}
Animation.prototype.toModel = function () {
var e_1, _a;
@@ -1409,7 +1410,8 @@ var Animation = /** @class */ (function () {
repeatCount: this.repeatCount,
repeatMode: this.repeatMode,
fillMode: this.fillMode,
timingFunction: this.timingFunction
timingFunction: this.timingFunction,
id: this.id,
};
};
return Animation;
@@ -1480,13 +1482,13 @@ var TranslationAnimation = /** @class */ (function (_super) {
var _this = _super.call(this) || this;
_this.translationXChangeable = {
key: "translationX",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
_this.translationYChangeable = {
key: "translationY",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
_this.changeables.set("translationX", _this.translationXChangeable);
_this.changeables.set("translationY", _this.translationYChangeable);
@@ -1640,6 +1642,7 @@ var AnimationSet = /** @class */ (function () {
function AnimationSet() {
this.animations = [];
this._duration = 0;
this.id = uniqueId("AnimationSet");
}
AnimationSet.prototype.addAnimation = function (anim) {
this.animations.push(anim);
@@ -1661,6 +1664,7 @@ var AnimationSet = /** @class */ (function () {
return e.toModel();
}),
delay: this.delay,
id: this.id,
};
};
return AnimationSet;

View File

@@ -314,6 +314,15 @@ class View {
}
});
}
cancelAnimation(context, animation) {
return this.nativeChannel(context, "cancelAnimation")(animation.id).then(() => {
this.__dirty_props__.translationX = this.translationX || 0;
this.__dirty_props__.translationY = this.translationY || 0;
this.__dirty_props__.scaleX = this.scaleX || 1;
this.__dirty_props__.scaleY = this.scaleY || 1;
this.__dirty_props__.rotation = this.rotation || 0;
});
}
}
__decorate$d([
Property,
@@ -1051,6 +1060,7 @@ class Animation {
this.changeables = new Map;
this.duration = 0;
this.fillMode = exports.FillMode.Forward;
this.id = uniqueId("Animation");
}
toModel() {
const changeables = [];
@@ -1069,7 +1079,8 @@ class Animation {
repeatCount: this.repeatCount,
repeatMode: this.repeatMode,
fillMode: this.fillMode,
timingFunction: this.timingFunction
timingFunction: this.timingFunction,
id: this.id,
};
}
}
@@ -1119,13 +1130,13 @@ class TranslationAnimation extends Animation {
super();
this.translationXChangeable = {
key: "translationX",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
this.translationYChangeable = {
key: "translationY",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
this.changeables.set("translationX", this.translationXChangeable);
this.changeables.set("translationY", this.translationYChangeable);
@@ -1228,6 +1239,7 @@ class AnimationSet {
constructor() {
this.animations = [];
this._duration = 0;
this.id = uniqueId("AnimationSet");
}
addAnimation(anim) {
this.animations.push(anim);
@@ -1245,6 +1257,7 @@ class AnimationSet {
return e.toModel();
}),
delay: this.delay,
id: this.id,
};
}
}

View File

@@ -1835,6 +1835,15 @@ class View {
}
});
}
cancelAnimation(context, animation) {
return this.nativeChannel(context, "cancelAnimation")(animation.id).then(() => {
this.__dirty_props__.translationX = this.translationX || 0;
this.__dirty_props__.translationY = this.translationY || 0;
this.__dirty_props__.scaleX = this.scaleX || 1;
this.__dirty_props__.scaleY = this.scaleY || 1;
this.__dirty_props__.rotation = this.rotation || 0;
});
}
}
__decorate$d([
Property,
@@ -2572,6 +2581,7 @@ class Animation {
this.changeables = new Map;
this.duration = 0;
this.fillMode = exports.FillMode.Forward;
this.id = uniqueId("Animation");
}
toModel() {
const changeables = [];
@@ -2590,7 +2600,8 @@ class Animation {
repeatCount: this.repeatCount,
repeatMode: this.repeatMode,
fillMode: this.fillMode,
timingFunction: this.timingFunction
timingFunction: this.timingFunction,
id: this.id,
};
}
}
@@ -2640,13 +2651,13 @@ class TranslationAnimation extends Animation {
super();
this.translationXChangeable = {
key: "translationX",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
this.translationYChangeable = {
key: "translationY",
fromValue: 1,
toValue: 1,
fromValue: 0,
toValue: 0,
};
this.changeables.set("translationX", this.translationXChangeable);
this.changeables.set("translationY", this.translationYChangeable);
@@ -2749,6 +2760,7 @@ class AnimationSet {
constructor() {
this.animations = [];
this._duration = 0;
this.id = uniqueId("AnimationSet");
}
addAnimation(anim) {
this.animations.push(anim);
@@ -2766,6 +2778,7 @@ class AnimationSet {
return e.toModel();
}),
delay: this.delay,
id: this.id,
};
}
}