Skip to content

Commit bcde968

Browse files
authored
fix(animations): set nodeType 'element' to newly created views (#720)
this is required because of checks in DomAnimationEngine Caused by: angular/angular@80075af
1 parent 184f887 commit bcde968

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

Diff for: nativescript-angular/animations/animation-engine.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
setStyles,
1414
} from "./dom-utils";
1515

16-
const MARKED_FOR_ANIMATION = "ng-animate";
16+
const MARKED_FOR_ANIMATION_CLASSNAME = "ng-animating";
17+
const MARKED_FOR_ANIMATION_SELECTOR = ".ng-animating";
1718

1819
interface QueuedAnimationTransitionTuple {
1920
element: NgView;
@@ -50,9 +51,9 @@ export class NativeScriptAnimationEngine extends DomAnimationEngine {
5051
// we first run this so that the previous animation player
5152
// data can be passed into the successive animation players
5253
let totalTime = 0;
53-
const players = instruction.timelines.map(timelineInstruction => {
54+
const players = instruction.timelines.map((timelineInstruction, i) => {
5455
totalTime = Math.max(totalTime, timelineInstruction.totalTime);
55-
return (<any>this)._buildPlayer(element, timelineInstruction, previousPlayers);
56+
return (<any>this)._buildPlayer(element, timelineInstruction, previousPlayers, i);
5657
});
5758

5859
previousPlayers.forEach(previousPlayer => previousPlayer.destroy());
@@ -91,7 +92,7 @@ export class NativeScriptAnimationEngine extends DomAnimationEngine {
9192
// them out by destroying each of them.
9293
let elms = [];
9394
(<any>element)._eachChildView(child => {
94-
if (cssClasses(<NgView>child).get(MARKED_FOR_ANIMATION)) {
95+
if (cssClasses(<NgView>child).get(MARKED_FOR_ANIMATION_SELECTOR)) {
9596
elms.push(child);
9697
}
9798

@@ -129,8 +130,8 @@ export class NativeScriptAnimationEngine extends DomAnimationEngine {
129130
(<any>this)._queuedTransitionAnimations.push(tuple);
130131
player.init();
131132

132-
cssClasses(element).set(MARKED_FOR_ANIMATION, true);
133-
player.onDone(() => cssClasses(element).set(MARKED_FOR_ANIMATION, false));
133+
cssClasses(element).set(MARKED_FOR_ANIMATION_CLASSNAME, true);
134+
player.onDone(() => cssClasses(element).set(MARKED_FOR_ANIMATION_CLASSNAME, false));
134135
}
135136

136137
private _getElementAnimation(element: NgView) {

Diff for: nativescript-angular/element-registry.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface ViewClassMeta {
99
}
1010

1111
export interface ViewExtensions {
12+
nodeType: number;
1213
nodeName: string;
1314
templateParent: NgView;
1415
ngCssClasses: Map<string, boolean>;

Diff for: nativescript-angular/view-util.ts

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { platformNames, Device } from "platform";
1717
import { rendererLog as traceLog, styleError } from "./trace";
1818

1919
const XML_ATTRIBUTES = Object.freeze(["style", "rows", "columns", "fontAttributes"]);
20+
const ELEMENT_NODE_TYPE = 1;
2021
const whiteSpaceSplitter = /\s+/;
2122

2223
export type ViewExtensions = ViewExtensions;
@@ -144,6 +145,13 @@ export class ViewUtil {
144145
view.nodeName = name;
145146
view.meta = getViewMeta(name);
146147

148+
// we're setting the node type of the view
149+
// to 'element' because of checks done in the
150+
// dom animation engine:
151+
// tslint:disable-next-line:max-line-length
152+
// https://github.com/angular/angular/blob/master/packages/animations/browser/src/render/dom_animation_engine.ts#L70-L81
153+
view.nodeType = ELEMENT_NODE_TYPE;
154+
147155
return view;
148156
}
149157

Diff for: tests/app/tests/property-sets.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {createDevice} from "./test-utils";
99

1010
class TestView extends View implements ViewExtensions {
1111
public nodeName: string = "TestView";
12+
public nodeType: number = 1;
1213
public templateParent: NgView = null;
1314
public meta: ViewClassMeta = { skipAddToDom: false };
1415
public ngCssClasses: Map<string, boolean> = new Map<string, boolean>();

0 commit comments

Comments
 (0)