Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-galka committed Mar 13, 2017
1 parent 58c0113 commit b3896e4
Show file tree
Hide file tree
Showing 51 changed files with 753 additions and 502 deletions.
57 changes: 0 additions & 57 deletions .angular-cli.json

This file was deleted.

2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ testem.log
#System Files
.DS_Store
Thumbs.db

# lib
/aot
/lib/*.map
/lib/*.js
/lib/*.json
/lib/*.d.ts
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
aot/
.editorconfig
clean.sh
tsconfig.json
tslint.json
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<a name="0.1.0"></a>
# 0.1.0 (2017-03-13)
28 changes: 1 addition & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1 @@
# NgxSimpleGallery

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0-rc.1.

## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
# NgxGallery
7 changes: 7 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

rm lib/*.map
rm lib/*.js
rm lib/*.json
rm lib/*.d.ts
rm -rf aot
14 changes: 0 additions & 14 deletions e2e/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions e2e/app.po.ts

This file was deleted.

19 changes: 0 additions & 19 deletions e2e/tsconfig.e2e.json

This file was deleted.

44 changes: 0 additions & 44 deletions karma.conf.js

This file was deleted.

4 changes: 4 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './ngx-gallery.component'
export * from './ngx-gallery.module'
export * from './ngx-gallery-options.model';
export * from './ngx-gallery-image.model';
6 changes: 6 additions & 0 deletions lib/ngx-gallery-arrows.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="ngx-gallery-arrow-wrapper ngx-gallery-arrow-left">
<i class="fa fa-arrow-circle-left" aria-hidden="true" (click)="handlePrevClick()" [class.ngx-gallery-disabled]="prevDisabled"></i>
</div>
<div class="ngx-gallery-arrow-wrapper ngx-gallery-arrow-right">
<i class="fa fa-arrow-circle-right" aria-hidden="true" (click)="handleNextClick()" [class.ngx-gallery-disabled]="nextDisabled"></i>
</div>
37 changes: 37 additions & 0 deletions lib/ngx-gallery-arrows.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.ngx-gallery-arrow-wrapper {
position: absolute;
height: 100%;
width: 0px;
display: table;
z-index: 2000;
table-layout: fixed;
}

.ngx-gallery-arrow-wrapper.ngx-gallery-arrow-left {
left: 0px;
}

.ngx-gallery-arrow-wrapper.ngx-gallery-arrow-right {
right: 0px;
}

.fa {
&.fa-arrow-circle-left, &.fa-arrow-circle-right {
top: 50%;
transform: translateY(-50%);
cursor: pointer;

&.ngx-gallery-disabled {
opacity: 0.6;
cursor: default;
}
}

&.fa-arrow-circle-left {
left: 10px;
}

&.fa-arrow-circle-right {
right: 10px;
}
}
22 changes: 22 additions & 0 deletions lib/ngx-gallery-arrows.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, Input, Output, EventEmitter, } from '@angular/core';

@Component({
selector: 'ngx-gallery-arrows',
templateUrl: './ngx-gallery-arrows.component.html',
styleUrls: ['./ngx-gallery-arrows.component.scss']
})
export class NgxGalleryArrowsComponent {
@Input() prevDisabled: boolean;
@Input() nextDisabled: boolean;

@Output() onPrevClick = new EventEmitter();
@Output() onNextClick = new EventEmitter();

handlePrevClick(): void {
this.onPrevClick.emit();
}

handleNextClick(): void {
this.onNextClick.emit();
}
}
2 changes: 2 additions & 0 deletions lib/ngx-gallery-image.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="ngx-gallery-image" *ngFor="let image of images; let i = index" [ngClass]="{'ngx-gallery-active': selectedIndex == i, 'ngx-gallery-clickable': clickable}" [style.background-image]="'url(' + image + ')'" (click)="handleClick($event, i)"></div>
<ngx-gallery-arrows *ngIf="arrows" (onPrevClick)="showPrev()" (onNextClick)="showNext()" [prevDisabled]="!canShowPrev()" [nextDisabled]="!canShowNext()" ></ngx-gallery-arrows>
28 changes: 28 additions & 0 deletions lib/ngx-gallery-image.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
:host {
width: 100%;
display: inline-block;
position: relative;
}

.ngx-gallery-image {
background-size: cover;
background-position: center;
height: 100%;
width: 100%;
position: absolute;
left: 0px;
top: 0px;
opacity: 0;
transition: opacity 0.5s ease-in-out;

&.ngx-gallery-active {
opacity: 1;
z-index: 1000;
}

&.ngx-gallery-clickable {
cursor: pointer;
}
}


66 changes: 66 additions & 0 deletions lib/ngx-gallery-image.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Component, Input, Output, EventEmitter, HostListener, OnInit } from '@angular/core';

@Component({
selector: 'ngx-gallery-image',
templateUrl: './ngx-gallery-image.component.html',
styleUrls: ['./ngx-gallery-image.component.scss']
})
export class NgxGalleryImageComponent implements OnInit {
@Input() images: string[];
@Input() clickable: boolean;
@Input() selectedIndex: number;
@Input() arrows: boolean;
@Input() arrowsAutoHide: boolean;

@Output() onClick = new EventEmitter();
@Output() onActiveChange = new EventEmitter();

ngOnInit(): void {
if(this.arrows && this.arrowsAutoHide) {
this.arrows = false;
}
}

@HostListener('mouseenter') onMouseEnter() {
if(this.arrowsAutoHide && !this.arrows) {
this.arrows = true;
}
}

@HostListener('mouseleave') onMouseLeave() {
if(this.arrowsAutoHide && this.arrows) {
this.arrows = false;
}
}

handleClick(event: Event, index: number): void {
if (this.clickable) {
this.onClick.emit(index);

event.stopPropagation();
event.preventDefault();
}
}

showNext(): void {
if (this.canShowNext()) {
this.selectedIndex++;
this.onActiveChange.emit(this.selectedIndex);
}
}

showPrev(): void {
if (this.canShowPrev()) {
this.selectedIndex--;
this.onActiveChange.emit(this.selectedIndex);
}
}

canShowNext(): boolean {
return this.selectedIndex < this.images.length - 1 ? true : false;
}

canShowPrev(): boolean {
return this.selectedIndex > 0 ? true : false;
}
}
Loading

0 comments on commit b3896e4

Please sign in to comment.