Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 198f853

Browse files
author
vakrilov
committed
Remove ANIMATION_DRIVER token
1 parent 52a8c32 commit 198f853

File tree

4 files changed

+37
-40
lines changed

4 files changed

+37
-40
lines changed

‎nativescript-angular/animation-driver.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class NativeScriptAnimationDriver implements AnimationDriver {
1111
computeStyle(element: any, prop: string): string {
1212
return (<View>element).style._getValue(styleProperty.getPropertyByCssName(prop));
1313
}
14-
14+
1515
animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string): AnimationPlayer {
1616
return new NativeScriptAnimationPlayer(element, keyframes, duration, delay, easing);
1717
}

‎nativescript-angular/animation-player.ts‎

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { AnimationKeyframe } from '@angular/core/src/animation/animation_keyframe';
22
import { AnimationPlayer } from '@angular/core/src/animation/animation_player';
3-
import { AnimationStyles } from '@angular/core/src/animation/animation_styles';
4-
import { AnimationDriver } from '@angular/core/src/animation/animation_driver';
53
import { KeyframeAnimation, KeyframeAnimationInfo, KeyframeInfo, KeyframeDeclaration } from 'ui/animation/keyframe-animation';
64
import { View } from "ui/core/view";
75
import enums = require("ui/enums");
@@ -10,14 +8,14 @@ import observable = require('ui/core/dependency-observable');
108
import types = require("utils/types");
119

1210
export class NativeScriptAnimationPlayer implements AnimationPlayer {
13-
11+
1412
public parentPlayer: AnimationPlayer;
1513

1614
private _subscriptions: Function[] = [];
1715
private _finished = false;
1816
private animation: KeyframeAnimation;
1917
private target: View;
20-
18+
2119
constructor(element: Node, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string) {
2220

2321
this.parentPlayer = null;
@@ -52,14 +50,14 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
5250
if (typeof value === "string" && property.valueConverter) {
5351
value = property.valueConverter(<string>value);
5452
}
55-
keyframeInfo.declarations.push({ property: property.name, value: value })
53+
keyframeInfo.declarations.push({ property: property.name, value: value });
5654
}
5755
else if (typeof value === "string" && substyle === "transform") {
5856
NativeScriptAnimationPlayer.parseTransform(<string>value, keyframeInfo);
5957
}
6058
}
6159
}
62-
keyframeAnimationInfo.keyframes.push(keyframeInfo)
60+
keyframeAnimationInfo.keyframes.push(keyframeInfo);
6361
}
6462

6563
this.animation = KeyframeAnimation.keyframeAnimationFromInfo(keyframeAnimationInfo, observable.ValueSource.VisualState);
@@ -79,7 +77,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
7977
if (this.animation) {
8078
this.animation.play(this.target)
8179
.then(() => { this._onFinish(); })
82-
.catch((e) => {});
80+
.catch((e) => {});
8381
}
8482
}
8583

@@ -110,11 +108,11 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
110108
setPosition(p: any): void {
111109
throw new Error("AnimationPlayer.setPosition method is not supported!");
112110
}
113-
111+
114112
getPosition(): number {
115113
return 0;
116114
}
117-
115+
118116
static animationTimingFunctionConverter(value): any {
119117
switch (value) {
120118
case "ease":
@@ -136,9 +134,9 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
136134
throw new Error("Invalid value for animation: " + value);
137135
}
138136
return enums.AnimationCurve.cubicBezier(
139-
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[0]),
140-
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[1]),
141-
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[2]),
137+
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[0]),
138+
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[1]),
139+
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[2]),
142140
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[3]));
143141
}
144142
else {
@@ -154,7 +152,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
154152
return result;
155153
}
156154

157-
static transformConverter(value: any): Object {
155+
static transformConverter(value: any): Object {
158156
if (value === "none") {
159157
let operations = {};
160158
operations[value] = value;
@@ -166,20 +164,20 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
166164
let pos = 0;
167165
while (pos < value.length) {
168166
if (value[pos] === " " || value[pos] === ",") {
169-
pos++;
167+
pos++;
170168
}
171169
else if (value[pos] === "(") {
172170
let start = pos + 1;
173171
while (pos < value.length && value[pos] !== ")") {
174-
pos++;
172+
pos++;
175173
}
176174
let operand = value.substring(start, pos);
177175
operations[operator] = operand.trim();
178176
operator = "";
179-
pos++;
177+
pos++;
180178
}
181179
else {
182-
operator += value[pos++];
180+
operator += value[pos++];
183181
}
184182
}
185183
return operations;
@@ -196,29 +194,29 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
196194
for (let transform in newTransform) {
197195
switch (transform) {
198196
case "scaleX":
199-
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(newTransform[transform]), y: 1 } });
197+
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(newTransform[transform]), y: 1 } });
200198
break;
201199
case "scaleY":
202-
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: parseFloat(newTransform[transform]) } });
200+
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: parseFloat(newTransform[transform]) } });
203201
break;
204202
case "scale":
205203
case "scale3d":
206204
values = newTransform[transform].split(",");
207205
if (values.length === 2 || values.length === 3) {
208-
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
206+
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
209207
}
210208
break;
211209
case "translateX":
212-
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(newTransform[transform]), y: 0 } });
210+
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(newTransform[transform]), y: 0 } });
213211
break;
214212
case "translateY":
215-
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: parseFloat(newTransform[transform]) } });
213+
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: parseFloat(newTransform[transform]) } });
216214
break;
217215
case "translate":
218216
case "translate3d":
219217
values = newTransform[transform].split(",");
220218
if (values.length === 2 || values.length === 3) {
221-
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
219+
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
222220
}
223221
break;
224222
case "rotate":
@@ -227,11 +225,11 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
227225
if (text.slice(-3) === "rad") {
228226
val = val * (180.0 / Math.PI);
229227
}
230-
animationInfo.declarations.push({ property: "rotate", value: val });
228+
animationInfo.declarations.push({ property: "rotate", value: val });
231229
case "none":
232-
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: 1 } });
233-
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: 0 } });
234-
animationInfo.declarations.push({ property: "rotate", value: 0 });
230+
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: 1 } });
231+
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: 0 } });
232+
animationInfo.declarations.push({ property: "rotate", value: 0 });
235233
break;
236234
}
237235
}

‎nativescript-angular/platform-providers.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {topmost} from 'ui/frame';
22
import {Page} from 'ui/page';
33
import {provide, Provider, OpaqueToken} from '@angular/core/src/di';
4-
import {Device, ScreenMetrics, device, screen} from "platform";
4+
import {device} from "platform";
55
import {NativeScriptAnimationDriver} from './animation-driver';
6+
import {AnimationDriver} from "@angular/core/src/animation/animation_driver";
67

78
export const APP_ROOT_VIEW = new OpaqueToken('App Root View');
89
export const DEVICE = new OpaqueToken('platfrom device');
9-
export const ANIMATION_DRIVER = new OpaqueToken('animation driver');
1010

1111
export const defaultPageProvider = provide(Page, { useFactory: getDefaultPage });
1212

@@ -21,4 +21,4 @@ export function getDefaultPage(): Page {
2121

2222
export const defaultDeviceProvider = provide(DEVICE, { useValue: device });
2323

24-
export const defaultAnimationDriverProvider = provide(ANIMATION_DRIVER, { useClass: NativeScriptAnimationDriver });
24+
export const defaultAnimationDriverProvider = provide(AnimationDriver, { useClass: NativeScriptAnimationDriver });

‎nativescript-angular/renderer.ts‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AnimationKeyframe } from '@angular/core/src/animation/animation_keyfram
99
import { AnimationPlayer } from '@angular/core/src/animation/animation_player';
1010
import { AnimationStyles } from '@angular/core/src/animation/animation_styles';
1111
import { AnimationDriver } from '@angular/core/src/animation/animation_driver';
12-
import {APP_ROOT_VIEW, DEVICE, ANIMATION_DRIVER} from "./platform-providers";
12+
import {APP_ROOT_VIEW, DEVICE} from "./platform-providers";
1313
import {isBlank} from '@angular/core/src/facade/lang';
1414
import {CONTENT_ATTR} from '@angular/platform-browser/src/dom/dom_renderer';
1515
import {View} from "ui/core/view";
@@ -23,14 +23,13 @@ import { Device } from "platform";
2323

2424
@Injectable()
2525
export class NativeScriptRootRenderer implements RootRenderer {
26-
private _rootView: View = null;
2726
private _viewUtil: ViewUtil;
28-
private _animationDriver: AnimationDriver;
2927

30-
constructor( @Optional() @Inject(APP_ROOT_VIEW) rootView: View, @Inject(DEVICE) device: Device, @Inject(ANIMATION_DRIVER) animationDriver) {
31-
this._rootView = rootView;
28+
constructor(
29+
@Optional() @Inject(APP_ROOT_VIEW) private _rootView: View,
30+
@Inject(DEVICE) device: Device,
31+
private _animationDriver: AnimationDriver) {
3232
this._viewUtil = new ViewUtil(device);
33-
this._animationDriver = animationDriver;
3433
}
3534

3635
private _registeredComponents: Map<string, NativeScriptRenderer> = new Map<string, NativeScriptRenderer>();
@@ -51,7 +50,7 @@ export class NativeScriptRootRenderer implements RootRenderer {
5150
}
5251

5352
renderComponent(componentProto: RenderComponentType): Renderer {
54-
var renderer = this._registeredComponents.get(componentProto.id);
53+
let renderer = this._registeredComponents.get(componentProto.id);
5554
if (isBlank(renderer)) {
5655
renderer = new NativeScriptRenderer(this, componentProto, this._animationDriver);
5756
this._registeredComponents.set(componentProto.id, renderer);
@@ -129,8 +128,8 @@ export class NativeScriptRenderer extends Renderer {
129128

130129
detachView(viewRootNodes: NgView[]) {
131130
traceLog('NativeScriptRenderer.detachView');
132-
for (var i = 0; i < viewRootNodes.length; i++) {
133-
var node = viewRootNodes[i];
131+
for (let i = 0; i < viewRootNodes.length; i++) {
132+
let node = viewRootNodes[i];
134133
this.viewUtil.removeChild(<NgView>node.parent, node);
135134
}
136135
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /