Skip to content

Linting #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ install:
- tns error-reporting disable
- cd nativescript-angular
- npm install
- npm run tslint
- cd ../tests
- npm install
- tns platform add android
Expand Down
3 changes: 2 additions & 1 deletion nativescript-angular/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
tsconfig.json
global.d.ts
.npmignore
gulpfile.js
gulpfile.js
tslint.json
13 changes: 10 additions & 3 deletions nativescript-angular/animation-driver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AnimationPlayer } from "@angular/core";
import { AnimationStyles, AnimationKeyframe } from "./private_import_core";
import { NativeScriptAnimationPlayer } from './animation-player';
import { NativeScriptAnimationPlayer } from "./animation-player";
import { View } from "ui/core/view";
import { getPropertyByCssName } from 'ui/styling/style-property';
import { getPropertyByCssName } from "ui/styling/style-property";

export abstract class AnimationDriver {
abstract animate(
Expand All @@ -16,7 +16,14 @@ export class NativeScriptAnimationDriver implements AnimationDriver {
return (<View>element).style._getValue(getPropertyByCssName(prop));
}

animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string): AnimationPlayer {
animate(
element: any,
_startingStyles: AnimationStyles,
keyframes: AnimationKeyframe[],
duration: number,
delay: number,
easing: string
): AnimationPlayer {
return new NativeScriptAnimationPlayer(element, keyframes, duration, delay, easing);
}
}
86 changes: 59 additions & 27 deletions nativescript-angular/animation-player.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { AnimationPlayer } from "@angular/core";
import { AnimationKeyframe } from "./private_import_core";
import { KeyframeAnimation, KeyframeAnimationInfo, KeyframeInfo, KeyframeDeclaration } from 'ui/animation/keyframe-animation';
import {
KeyframeAnimation,
KeyframeAnimationInfo,
KeyframeInfo,
KeyframeDeclaration
} from "ui/animation/keyframe-animation";
import { View } from "ui/core/view";
import { AnimationCurve } from "ui/enums";
import { ValueSource } from 'ui/core/dependency-observable';
import { ValueSource } from "ui/core/dependency-observable";
import { isString } from "utils/types";
import * as styleProperty from 'ui/styling/style-property';
import * as styleProperty from "ui/styling/style-property";

export class NativeScriptAnimationPlayer implements AnimationPlayer {

Expand All @@ -18,7 +23,13 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
private animation: KeyframeAnimation;
private target: View;

constructor(element: Node, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string) {
constructor(
element: Node,
keyframes: AnimationKeyframe[],
duration: number,
delay: number,
easing: string
) {

this.parentPlayer = null;

Expand All @@ -36,7 +47,9 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
keyframeAnimationInfo.duration = duration;
keyframeAnimationInfo.delay = delay;
keyframeAnimationInfo.iterations = 1;
keyframeAnimationInfo.curve = easing ? NativeScriptAnimationPlayer.animationTimingFunctionConverter(easing) : AnimationCurve.ease;
keyframeAnimationInfo.curve = easing ?
NativeScriptAnimationPlayer.animationTimingFunctionConverter(easing) :
AnimationCurve.ease;
keyframeAnimationInfo.keyframes = new Array<KeyframeInfo>();
keyframeAnimationInfo.isForwards = true;

Expand All @@ -53,16 +66,16 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
value = property.valueConverter(<string>value);
}
keyframeInfo.declarations.push({ property: property.name, value: value });
}
else if (typeof value === "string" && substyle === "transform") {
} else if (typeof value === "string" && substyle === "transform") {
NativeScriptAnimationPlayer.parseTransform(<string>value, keyframeInfo);
}
}
}
keyframeAnimationInfo.keyframes.push(keyframeInfo);
}

this.animation = KeyframeAnimation.keyframeAnimationFromInfo(keyframeAnimationInfo, ValueSource.VisualState);
this.animation = KeyframeAnimation.keyframeAnimationFromInfo(
keyframeAnimationInfo, ValueSource.VisualState);
}

init(): void {
Expand Down Expand Up @@ -98,7 +111,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
this._onStart();
this.animation.play(this.target)
.then(() => { this._onFinish(); })
.catch((e) => { });
.catch((_e) => { });
}
}

Expand Down Expand Up @@ -126,7 +139,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
this._onFinish();
}

setPosition(p: any): void {
setPosition(_p: any): void {
throw new Error("AnimationPlayer.setPosition method is not supported!");
}

Expand Down Expand Up @@ -159,8 +172,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[1]),
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[2]),
NativeScriptAnimationPlayer.bezieArgumentConverter(bezierArr[3]));
}
else {
} else {
throw new Error("Invalid value for animation: " + value);
}
}
Expand All @@ -178,16 +190,14 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
let operations = {};
operations[value] = value;
return operations;
}
else if (isString(value)) {
} else if (isString(value)) {
let operations = {};
let operator = "";
let pos = 0;
while (pos < value.length) {
if (value[pos] === " " || value[pos] === ",") {
pos++;
}
else if (value[pos] === "(") {
} else if (value[pos] === "(") {
let start = pos + 1;
while (pos < value.length && value[pos] !== ")") {
pos++;
Expand All @@ -196,14 +206,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
operations[operator] = operand.trim();
operator = "";
pos++;
}
else {
} else {
operator += value[pos++];
}
}
return operations;
}
else {
} else {
return undefined;
}
}
Expand All @@ -215,29 +223,50 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
for (let transform in newTransform) {
switch (transform) {
case "scaleX":
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(newTransform[transform]), y: 1 } });
animationInfo.declarations.push({
property: "scale",
value: { x: parseFloat(newTransform[transform]), y: 1 }
});
break;
case "scaleY":
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: parseFloat(newTransform[transform]) } });
animationInfo.declarations.push({
property: "scale",
value: { x: 1, y: parseFloat(newTransform[transform]) }
});
break;
case "scale":
case "scale3d":
values = newTransform[transform].split(",");
if (values.length === 2 || values.length === 3) {
animationInfo.declarations.push({ property: "scale", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
animationInfo.declarations.push({
property: "scale",
value: { x: parseFloat(values[0]), y: parseFloat(values[1]) }
});
}
break;
case "translateX":
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(newTransform[transform]), y: 0 } });
animationInfo.declarations.push({
property: "translate",
value: { x: parseFloat(newTransform[transform]), y: 0 }
});
break;
case "translateY":
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: parseFloat(newTransform[transform]) } });
animationInfo.declarations.push({
property: "translate",
value: { x: 0, y: parseFloat(newTransform[transform]) }
});
break;
case "translate":
case "translate3d":
values = newTransform[transform].split(",");
if (values.length === 2 || values.length === 3) {
animationInfo.declarations.push({ property: "translate", value: { x: parseFloat(values[0]), y: parseFloat(values[1]) } });
animationInfo.declarations.push({
property: "translate",
value: {
x: parseFloat(values[0]),
y: parseFloat(values[1])
}
});
}
break;
case "rotate":
Expand All @@ -250,9 +279,12 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
break;
case "none":
animationInfo.declarations.push({ property: "scale", value: { x: 1, y: 1 } });
animationInfo.declarations.push({ property: "translate", value: { x: 0, y: 0 } });
animationInfo.declarations.push(
{ property: "translate", value: { x: 0, y: 0 } });
animationInfo.declarations.push({ property: "rotate", value: 0 });
break;
default:
throw new Error("Unsupported transform: " + transform);
}
}
return array;
Expand Down
Loading