Revert "fix(animate): ensure transition properties are removed once the animation is over"
This reverts commit b8e69a21a9
.
This commit is contained in:
@ -34,8 +34,6 @@ export class Animation {
|
||||
|
||||
private _stringPrefix: string = '';
|
||||
|
||||
private _temporaryStyles: {[key: string]: string} = {};
|
||||
|
||||
/** total amount of time that the animation should take including delay */
|
||||
get totalTime(): number {
|
||||
let delay = this.computedDelay != null ? this.computedDelay : 0;
|
||||
@ -67,25 +65,10 @@ export class Animation {
|
||||
*/
|
||||
setup(): void {
|
||||
if (this.data.fromStyles != null) this.applyStyles(this.data.fromStyles);
|
||||
if (this.data.duration != null) {
|
||||
this._temporaryStyles['transitionDuration'] = this._readStyle('transitionDuration');
|
||||
if (this.data.duration != null)
|
||||
this.applyStyles({'transitionDuration': this.data.duration.toString() + 'ms'});
|
||||
}
|
||||
if (this.data.delay != null) {
|
||||
this._temporaryStyles['transitionDelay'] = this._readStyle('transitionDelay');
|
||||
if (this.data.delay != null)
|
||||
this.applyStyles({'transitionDelay': this.data.delay.toString() + 'ms'});
|
||||
}
|
||||
|
||||
if (!StringMapWrapper.isEmpty(this.data.animationStyles)) {
|
||||
// it's important that we setup a list of the styles and their
|
||||
// initial inline style values prior to applying the animation
|
||||
// styles such that we can restore the values after the animation
|
||||
// has been completed.
|
||||
StringMapWrapper.keys(this.data.animationStyles)
|
||||
.forEach((prop) => { this._temporaryStyles[prop] = this._readStyle(prop); });
|
||||
|
||||
this.applyStyles(this.data.animationStyles);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,8 +98,12 @@ export class Animation {
|
||||
*/
|
||||
applyStyles(styles: {[key: string]: any}): void {
|
||||
StringMapWrapper.forEach(styles, (value, key) => {
|
||||
var prop = this._formatStyleProp(key);
|
||||
DOM.setStyle(this.element, prop, value.toString());
|
||||
var dashCaseKey = camelCaseToDashCase(key);
|
||||
if (isPresent(DOM.getStyle(this.element, dashCaseKey))) {
|
||||
DOM.setStyle(this.element, dashCaseKey, value.toString());
|
||||
} else {
|
||||
DOM.setStyle(this.element, this._stringPrefix + dashCaseKey, value.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -136,26 +123,6 @@ export class Animation {
|
||||
for (let i = 0, len = classes.length; i < len; i++) DOM.removeClass(this.element, classes[i]);
|
||||
}
|
||||
|
||||
private _readStyle(prop: string): string {
|
||||
return DOM.getStyle(this.element, this._formatStyleProp(prop));
|
||||
}
|
||||
|
||||
private _formatStyleProp(prop: string): string {
|
||||
prop = camelCaseToDashCase(prop);
|
||||
return prop.indexOf('animation') >= 0 ? this._stringPrefix + prop : prop;
|
||||
}
|
||||
|
||||
private _removeAndRestoreStyles(styles: {[key: string]: string}): void {
|
||||
StringMapWrapper.forEach(styles, (value, prop) => {
|
||||
prop = this._formatStyleProp(prop);
|
||||
if (value.length > 0) {
|
||||
DOM.setStyle(this.element, prop, value);
|
||||
} else {
|
||||
DOM.removeStyle(this.element, prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds events to track when animations have finished
|
||||
*/
|
||||
@ -180,9 +147,6 @@ export class Animation {
|
||||
*/
|
||||
handleAnimationCompleted(): void {
|
||||
this.removeClasses(this.data.animationClasses);
|
||||
this._removeAndRestoreStyles(this._temporaryStyles);
|
||||
this._temporaryStyles = {};
|
||||
|
||||
this.callbacks.forEach(callback => callback());
|
||||
this.callbacks = [];
|
||||
this.eventClearFunctions.forEach(fn => fn());
|
||||
|
@ -14,9 +14,6 @@ export class CssAnimationOptions {
|
||||
/** classes to be added for the duration of the animation */
|
||||
animationClasses: string[] = [];
|
||||
|
||||
/** styles to be applied for the duration of the animation */
|
||||
animationStyles: {[key: string]: string} = {};
|
||||
|
||||
/** override the duration of the animation (in milliseconds) */
|
||||
duration: number;
|
||||
|
||||
|
Reference in New Issue
Block a user