Skip to content

Commit

Permalink
perf(animations): do not place enterId values on elements for queryin…
Browse files Browse the repository at this point in the history
…g purposes (#17150)
  • Loading branch information
matsko authored and vicb committed Jun 1, 2017
1 parent 230255f commit ad6a57e
Showing 1 changed file with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {AnimationDriver} from './animation_driver';
import {getOrSetAsInMap, listenOnPlayer, makeAnimationEvent, normalizeKeyframes, optimizeGroupPlayer} from './shared';

const EMPTY_PLAYER_ARRAY: AnimationPlayer[] = [];
const ANIMATE_EPOCH_ATTR = 'ng-animate-id';

interface TriggerListener {
name: string;
Expand Down Expand Up @@ -454,14 +453,14 @@ export class TransitionAnimationEngine {
public statesByElement = new Map<any, {[triggerName: string]: StateValue}>();
public totalAnimations = 0;
public totalQueuedPlayers = 0;
public currentEpochId = 0;

private _namespaceLookup: {[id: string]: AnimationTransitionNamespace} = {};
private _namespaceList: AnimationTransitionNamespace[] = [];
private _flushFns: (() => any)[] = [];
private _whenQuietFns: (() => any)[] = [];

public namespacesByHostElement = new Map<any, AnimationTransitionNamespace>();
public collectedElements: any[] = [];

// this method is designed to be overridden by the code that uses this engine
public onRemovalComplete = (element: any, context: any) => {};
Expand Down Expand Up @@ -590,10 +589,7 @@ export class TransitionAnimationEngine {
}
}

updateElementEpoch(element: any, isRemoval?: boolean) {
const epoch = (isRemoval ? -1 : 1) * this.currentEpochId;
setAttribute(element, ANIMATE_EPOCH_ATTR, epoch);
}
updateElementEpoch(element: any, isRemoval?: boolean) { this.collectedElements.push(element); }

markElementAsRemoved(element: any, unmark?: boolean) {
if (unmark) {
Expand Down Expand Up @@ -679,6 +675,7 @@ export class TransitionAnimationEngine {
}

this.totalQueuedPlayers = 0;
this.collectedElements = [];
this.queuedRemovals.clear();
this._flushFns.forEach(fn => fn());
this._flushFns = [];
Expand All @@ -696,8 +693,6 @@ export class TransitionAnimationEngine {
quietFns.forEach(fn => fn());
}
}

this.currentEpochId++;
}

private _flushAnimations(microtaskId: number): TransitionAnimationPlayer[] {
Expand All @@ -713,8 +708,7 @@ export class TransitionAnimationEngine {
// the :enter queries match the elements (since the timeline queries
// are fired during instruction building).
const bodyNode = getBodyNode();
const allEnterNodes: any[] =
bodyNode ? this.driver.query(bodyNode, makeEpochSelector(this.currentEpochId), true) : [];
const allEnterNodes: any[] = this.collectedElements;
const enterNodes: any[] =
allEnterNodes.length ? collectEnterElements(this.driver, allEnterNodes) : [];

Expand Down Expand Up @@ -1321,8 +1315,3 @@ function getBodyNode(): any|null {
}
return null;
}

function makeEpochSelector(epochId: number, isRemoval?: boolean) {
const value = (isRemoval ? -1 : 1) * epochId;
return `[${ANIMATE_EPOCH_ATTR}="${value}"]`;
}

0 comments on commit ad6a57e

Please sign in to comment.