Skip to content

Commit 1587faf

Browse files
authored
Merge pull request nativescript-community#1 from elena-p/master
update angular directive name and use it in demo app
2 parents 4352a5e + 20b618a commit 1587faf

File tree

7 files changed

+55
-18
lines changed

7 files changed

+55
-18
lines changed
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<ActionBar title="NativeScript-Image Angular sample app">
22
</ActionBar>
3-
<GridLayout rows="*, auto, auto">
4-
<Image #imageView verticalAlignment="center" placeholderImageUri="res://ns_logo" src="https://raw.githubusercontent.com/Akylas/nativescript-image/master/examples-data/breakfast1.jpg"></Image>
5-
<Button text="Animate to 0" row="1" (tap)="onAnimateToZero($event)"></Button>
6-
<Button text="Animate to 1" row="2" (tap)="onAnimateToOne($event)"></Button>
3+
<GridLayout rows="*, auto, auto, auto, auto, auto">
4+
<NSImg #imageView
5+
verticalAlignment="center"
6+
placeholderImageUri="res://ns_logo"
7+
src="https://raw.githubusercontent.com/Akylas/nativescript-image/master/examples-data/breakfast1.jpg">
8+
</NSImg>
9+
<Button text="Set 1" row="1" (tap)="onSeOpacityTo1()"></Button>
10+
<Button text="Set 0.5" row="2" (tap)="onSeOpacityTo05()"></Button>
11+
<Button text="Set 0.1" row="3" (tap)="onSeOpacityTo01()"></Button>
12+
<Button text="Animate to 0.1" row="4" (tap)="onAnimateTo01()"></Button>
13+
<Button text="Animate to 1" row="5" (tap)="onAnimateTo1()"></Button>
714
</GridLayout>

demo-angular/app/components/app.component.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,29 @@ export class AppComponent implements OnInit {
1616

1717
}
1818

19-
onAnimateToZero(args) {
19+
onSeOpacityTo1() {
20+
this.imageViewComponent.nativeElement.opacity = 1;
21+
}
22+
23+
onSeOpacityTo01() {
24+
this.imageViewComponent.nativeElement.opacity = 0.1;
25+
}
26+
27+
onSeOpacityTo05() {
28+
this.imageViewComponent.nativeElement.opacity = 0.5;
29+
}
30+
31+
onAnimateTo01() {
2032
this.imageViewComponent.nativeElement.animate({
21-
opacity: 0,
33+
opacity: 0.1,
2234
duration: 500
2335
});
2436
}
2537

26-
onAnimateToOne(args) {
38+
onAnimateTo1() {
2739
this.imageViewComponent.nativeElement.animate({
2840
opacity: 1,
2941
duration: 500
3042
});
3143
}
32-
}
44+
}

demo-angular/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"nativescript": {
99
"id": "org.nativescript.imagedemoangular",
1010
"tns-android": {
11-
"version": "5.0.0"
11+
"version": "5.1.0"
12+
},
13+
"tns-ios": {
14+
"version": "5.1.0"
1215
}
1316
},
1417
"dependencies": {

demo-angular/tsconfig.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
"noLib": false,
88
"emitDecoratorMetadata": true,
99
"experimentalDecorators": true,
10-
"lib": ["es6", "dom", "es2015.iterable"],
10+
"lib": [
11+
"es6",
12+
"dom",
13+
"es2015.iterable"
14+
],
1115
"pretty": true,
1216
"allowUnreachableCode": false,
1317
"allowUnusedLabels": false,
@@ -19,11 +23,22 @@
1923
"noFallthroughCasesInSwitch": true,
2024
"baseUrl": ".",
2125
"paths": {
22-
"~/*": ["app/*"],
23-
"*": ["./node_modules/tns-core-modules/*", "./node_modules/*"]
26+
"~/*": [
27+
"app/*"
28+
],
29+
"*": [
30+
"./node_modules/tns-core-modules/*",
31+
"./node_modules/*"
32+
]
2433
}
2534
},
26-
"include": ["app/**/*", "references.d.ts"],
27-
"exclude": ["node_modules", "platforms"],
35+
"include": [
36+
"app/**/*",
37+
"references.d.ts"
38+
],
39+
"exclude": [
40+
"node_modules",
41+
"platforms"
42+
],
2843
"compileOnSave": false
29-
}
44+
}

plugin/image-common.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare enum ScaleType {
1313
FitEnd = "fitEnd",
1414
FitStart = "fitStart",
1515
FitXY = "fitXY",
16-
FocusCrop = "focusCrop",
16+
FocusCrop = "focusCrop"
1717
}
1818
export interface AnimatedImage {
1919
start(): void;

src/angular/nativescript-image-directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Directive } from '@angular/core';
22

33
@Directive({
4-
selector: 'Img'
4+
selector: 'NSImg'
55
})
66
export class ImgDirective {
77
constructor() {}

src/angular/nativescript-image.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ import { Img } from '../image';
1010
})
1111
export class TNSImageModule {}
1212

13-
registerElement('Img', () => Img);
13+
registerElement('NSImg', () => Img);

0 commit comments

Comments
 (0)