Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
feat(image-viewer): added action click output event
Browse files Browse the repository at this point in the history
  • Loading branch information
garygrossgarten committed Dec 14, 2018
1 parent 8110732 commit 9dd170a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion projects/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fivethree/core",
"version": "0.2.4",
"version": "0.2.5",
"description": "Fivethree Core Components",
"keywords": [
"fivethree",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<img class="thumbnail" [width]="width" [height]="height" #thumbnail *ngIf="thumbnailVisible" (click)="open($event)" [src]="src">
<img class="thumbnail" [width]="width" [height]="height" #thumbnail *ngIf="thumbnailVisible" (click)="open($event)"
[src]="src">
<div #backdrop [@backdrop] (@backdrop.done)="onEnter($event)" *ngIf="_isOpen" class="backdrop">
<ion-toolbar [@fade] *ngIf="_controlsVisible" color="translucent">
<ion-buttons slot="start">
Expand All @@ -10,12 +11,12 @@
<div #footer class="actions" [@fade] *ngIf="_controlsVisible">
<ion-grid fixed>
<ion-row>
<ion-col style="text-align: center;" *ngFor="let action of actions; let c = count" [size]="12 / c">
<ion-button color="light" *ngIf="action.name" [fill]="'clear'">
<ion-col style="text-align: center;" *ngFor="let action of actions; let c = count; let i = index" [size]="12 / c">
<ion-button (click)="onActionClicked(i)" color="light" *ngIf="action.name" [fill]="'clear'">
<ion-icon *ngIf="action.icon" slot="start" [name]="action.icon"></ion-icon>
{{action.name}}
</ion-button>
<fiv-ripple *ngIf="!action.name">
<fiv-ripple (fivClick)="onActionClicked(i)" *ngIf="!action.name">
<ion-icon *ngIf="action.icon" [fivCenter] [name]="action.icon"></ion-icon>
</fiv-ripple>
</ion-col>
Expand Down
12 changes: 12 additions & 0 deletions projects/core/src/lib/image-viewer/image-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class ImageViewerComponent implements OnInit {
@Input() pullDistance = 150;
@Input() actions: ImageViewerAction[] = [];
@Output() fivClose = new EventEmitter();
@Output() fivActionClick = new EventEmitter<number>();
componentRef: ComponentRef<ImageViewerComponent>;
_isOpen = false;
_controlsVisible = true;
Expand All @@ -107,6 +108,7 @@ export class ImageViewerComponent implements OnInit {
singletap: Subscription;
closeSub: Subscription;
pinchPan: Subscription;
actionSub: Subscription;

singletapHammer;
doubleTapHammer;
Expand Down Expand Up @@ -160,6 +162,11 @@ export class ImageViewerComponent implements OnInit {
this.thumbnailVisible = true;
});

this.actionSub = this.componentRef.instance.fivActionClick
.subscribe((ev) => {
this.fivActionClick.emit(ev);
});

this.appRef.attachView(this.componentRef.hostView);

const domElem = (this.componentRef.hostView as EmbeddedViewRef<any>)
Expand All @@ -185,6 +192,7 @@ export class ImageViewerComponent implements OnInit {
this.singletap.unsubscribe();
this.doubletap.unsubscribe();
this.pinchPan.unsubscribe();
this.actionSub.unsubscribe();
}

removeHammerManager(): any {
Expand Down Expand Up @@ -532,6 +540,10 @@ export class ImageViewerComponent implements OnInit {
getAbsoluteCenter() {
return { x: this.platform.width() / 2, y: this.platform.height() / 2 };
}

onActionClicked(index: number) {
this.fivActionClick.emit(index);
}
}


Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/image/image.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ion-content padding>

<ion-card>
<fiv-image-viewer [actions]="[{icon: 'md-trash', name: 'remove'},{icon: 'md-send', name: 'send'}]" [src]="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQRop4VKhcYOvhY8gLZEICF8ZnWhKFVi6zgsxSCXwEGi2uukej'"></fiv-image-viewer>
<fiv-image-viewer (fivActionClick)="onActionClick($event)" [actions]="[{icon: 'md-trash', name: 'remove'},{icon: 'md-send', name: 'send'}]" [src]="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQRop4VKhcYOvhY8gLZEICF8ZnWhKFVi6zgsxSCXwEGi2uukej'"></fiv-image-viewer>
<ion-card-header>
<ion-card-subtitle>Awesome Subtitle</ion-card-subtitle>
<ion-card-title>Awesome Title</ion-card-title>
Expand All @@ -17,8 +17,8 @@
</ion-card-content>
</ion-card>

<fiv-image-viewer [width]="103.5" [height]="122" [actions]="[{icon: 'md-trash'},{icon: 'md-send'},{icon: 'md-image'},{icon: 'md-share'}]"
<fiv-image-viewer (fivActionClick)="onActionClick($event)" [width]="103.5" [height]="122" [actions]="[{icon: 'md-trash'},{icon: 'md-send'},{icon: 'md-image'},{icon: 'md-share'}]"
[src]="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQRop4VKhcYOvhY8gLZEICF8ZnWhKFVi6zgsxSCXwEGi2uukej'"></fiv-image-viewer>
<fiv-image-viewer [width]="207" [height]="244" [actions]="[{name: 'Ablesung abschließen'}]" [src]="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQRop4VKhcYOvhY8gLZEICF8ZnWhKFVi6zgsxSCXwEGi2uukej'"></fiv-image-viewer>
<fiv-image-viewer (fivActionClick)="onActionClick($event)" [width]="207" [height]="244" [actions]="[{name: 'Ablesung abschließen'}]" [src]="'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRQRop4VKhcYOvhY8gLZEICF8ZnWhKFVi6zgsxSCXwEGi2uukej'"></fiv-image-viewer>

</ion-content>
4 changes: 4 additions & 0 deletions src/app/pages/image/image.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export class ImagePage implements OnInit {
ngOnInit() {
}

onActionClick(index) {
console.log('test', index);
}

}

0 comments on commit 9dd170a

Please sign in to comment.