-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Veetaha
committed
Jun 10, 2019
1 parent
9828238
commit 96224cb
Showing
12 changed files
with
134 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { GalleryModule, GALLERY_CONFIG, GalleryConfig } from '@ngx-gallery/core'; | ||
import { LightboxModule, LightboxConfig, LIGHTBOX_CONFIG } from '@ngx-gallery/lightbox'; | ||
|
||
const galleryConfig: GalleryConfig = { | ||
// determinate mode is currently broken | ||
// see https://github.com/MurhafSousli/ngx-gallery/issues/269 | ||
loadingMode: 'indeterminate' | ||
}; | ||
const lightboxConfig: LightboxConfig = { | ||
keyboardShortcuts: true | ||
}; | ||
|
||
@NgModule({ | ||
exports: [ | ||
BrowserAnimationsModule, | ||
GalleryModule, | ||
LightboxModule | ||
], | ||
providers: [ | ||
{ provide: GALLERY_CONFIG, useValue: galleryConfig }, | ||
{ provide: LIGHTBOX_CONFIG, useValue: lightboxConfig } | ||
] | ||
}) | ||
export class CommonGalleryModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 10 additions & 9 deletions
19
frontend/src/app/media/media-pictures/media-pictures.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<app-media-pictures> is under development | ||
|
||
<!-- <ui-carousel [infinite]="true"> | ||
<ui-carousel-item *ngFor="let imageSrc of screenshotSrcs"> | ||
<figure class="local-carousel-item"> | ||
<img [src]="imageSrc" class="local-carousel-item__payload" > | ||
</figure> | ||
</ui-carousel-item> | ||
</ui-carousel> --> | ||
<div class="local-root"> | ||
<button *ngFor="let image of images; index as i" | ||
mat-button | ||
(click)="openLightbox(i)" | ||
type="button" | ||
class="local-picture" | ||
> | ||
<img [src]="image.data.src" class="local-picture__img"/> | ||
</button> | ||
</div> |
22 changes: 13 additions & 9 deletions
22
frontend/src/app/media/media-pictures/media-pictures.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
.local-carousel-item { | ||
object-fit: contain; | ||
width: 100%; | ||
height: 100%; | ||
|
||
&__payload { | ||
object-fit: contain; | ||
.local { | ||
&-root { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); | ||
gap: 30px; | ||
} | ||
&-picture { | ||
padding: 0; | ||
overflow: hidden; | ||
display: block; | ||
width: 100%; | ||
border-radius: 8px; | ||
&__img { | ||
width: 100%; | ||
} | ||
} | ||
|
||
} |
45 changes: 44 additions & 1 deletion
45
frontend/src/app/media/media-pictures/media-pictures.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,54 @@ | ||
import _ from 'lodash'; | ||
import { Component } from '@angular/core'; | ||
import { Gallery, ImageItem, GalleryRef } from '@ngx-gallery/core'; | ||
import { Lightbox } from '@ngx-gallery/lightbox'; | ||
import { take } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'app-media-pictures', | ||
templateUrl: './media-pictures.component.html', | ||
styleUrls: ['./media-pictures.component.scss'] | ||
}) | ||
export class MediaPicturesComponent { | ||
readonly screenshotSrcs = _.times(6, i => `/assets/game-screenshot${i + 1}.jpg`); | ||
readonly galleryRef: GalleryRef; | ||
readonly galleryId = 'MediaPictures'; | ||
// 6 screenshots from '/assets/' dir, update this counter when amount of | ||
// pictures that need to be display in this gallery changes | ||
readonly images = _.times(6, i => { | ||
const imgUrl = `/assets/game-screenshot${i + 1}.jpg`; | ||
return new ImageItem({ src: imgUrl, thumb: imgUrl }); | ||
}); | ||
|
||
constructor( | ||
private readonly lightboxes: Lightbox, | ||
galleries: Gallery | ||
) { | ||
this.galleryRef = galleries.ref(this.galleryId); | ||
this.galleryRef.setConfig({ | ||
loadingStrategy: 'preload', // TODO: change to 'lazy' when gallery gets big | ||
thumbPosition: 'left' | ||
}); | ||
this.galleryRef.load(this.images); | ||
} | ||
|
||
onWheel = _.throttle( | ||
(e: WheelEvent) => { | ||
if (e.deltaY > 0) this.galleryRef.next(); | ||
else if (e.deltaY < 0) this.galleryRef.prev(); | ||
}, | ||
/* throttle time */ 400, | ||
{ leading: true } | ||
); | ||
|
||
async openLightbox(index: number) { | ||
this.lightboxes.open(index, this.galleryId, { | ||
panelClass: 'fullscreen' | ||
}); | ||
|
||
document.addEventListener('wheel', this.onWheel); | ||
|
||
await this.lightboxes.closed.pipe(take(1)).toPromise(); | ||
|
||
document.removeEventListener('wheel', this.onWheel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters