From c86fbf35095f94199cfc2ab101a57a4ced245414 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Sun, 5 Feb 2017 17:27:58 +0100 Subject: [PATCH] implementing map lightbox --- frontend/app/app.module.ts | 2 + .../lightbox.map.gallery.component.css | 65 ++++++++++ .../lightbox.map.gallery.component.html | 44 +++++++ .../lightbox.map.gallery.component.ts | 118 ++++++++++++++++++ .../app/gallery/map/map.gallery.component.css | 6 + .../gallery/map/map.gallery.component.html | 12 +- .../app/gallery/map/map.gallery.component.ts | 21 +++- 7 files changed, 262 insertions(+), 6 deletions(-) create mode 100644 frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css create mode 100644 frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html create mode 100644 frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts diff --git a/frontend/app/app.module.ts b/frontend/app/app.module.ts index 95146a6b..c0082091 100644 --- a/frontend/app/app.module.ts +++ b/frontend/app/app.module.ts @@ -28,6 +28,7 @@ import {GalleryComponent} from "./gallery/gallery.component"; import {StringifyRole} from "./pipes/StringifyRolePipe"; import {Config} from "./config/Config"; import {GalleryMapComponent} from "./gallery/map/map.gallery.component"; +import {GalleryMapLightboxComponent} from "./gallery/map/lightbox/lightbox.map.gallery.component"; @NgModule({ imports: [ @@ -51,6 +52,7 @@ import {GalleryMapComponent} from "./gallery/map/map.gallery.component"; GalleryDirectoryComponent, GalleryLightboxComponent, GalleryMapComponent, + GalleryMapLightboxComponent, FrameComponent, GallerySearchComponent, GalleryNavigatorComponent, diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css new file mode 100644 index 00000000..1ad5ad6c --- /dev/null +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.css @@ -0,0 +1,65 @@ +.lightbox { + position: fixed; /* Stay in place */ + z-index: 1100; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: hidden; + display: flex; /* add */ + justify-content: center; /* add to align horizontal */ + align-items: center; /* add to align vertical */ + cursor: pointer; + transition: all 0.3s ease-in-out; +} + +.sebm-google-map-container { + width: 100%; + height: 100%; +} + +.blackCanvas { + position: fixed; /* Stay in place */ + z-index: 1099; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + background-color: black; + transition: all 0.3s ease-in-out; +} + +#controllers-container { + z-index: 1100; + right: 0; + top: 0; + position: fixed; +} + +#controls { + top: 0; + height: initial; + text-align: right; + width: 100%; + padding: 5px; + font-size: large; +} + +#controls span { + margin-left: 6px; + margin-right: 6px; + color: black; + cursor: pointer; +} + +.highlight { + opacity: 0.4; + transition: opacity .2s ease-out; + -moz-transition: opacity .2s ease-out; + -webkit-transition: opacity .2s ease-out; + -o-transition: opacity .2s ease-out; +} + +.highlight:hover { + opacity: 1.0; +} \ No newline at end of file diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html new file mode 100644 index 00000000..5d266ce0 --- /dev/null +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.html @@ -0,0 +1,44 @@ +
+ + + + + +
+
+ + + + + + + + + +
+ +
+
diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts new file mode 100644 index 00000000..26d064e6 --- /dev/null +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -0,0 +1,118 @@ +import {Component, Input, OnChanges, ElementRef, ViewChild} from "@angular/core"; +import {PhotoDTO} from "../../../../../common/entities/PhotoDTO"; +import {Dimension} from "../../../model/IRenderable"; +import {FullScreenService} from "../../fullscreen.service"; +import {Utils} from "../../../../../common/Utils"; +import {SebmGoogleMap} from "angular2-google-maps/core"; + +@Component({ + selector: 'gallery-map-lightbox', + styleUrls: ['app/gallery/map/lightbox/lightbox.map.gallery.component.css'], + templateUrl: 'app/gallery/map/lightbox/lightbox.map.gallery.component.html', +}) +export class GalleryMapLightboxComponent implements OnChanges { + + @Input() photos: Array; + private startPosition = null; + public lightboxDimension: Dimension = {top: 0, left: 0, width: 0, height: 0}; + public mapDimension: Dimension = {top: 0, left: 0, width: 0, height: 0}; + private visible = false; + private opacity = 1.0; + mapPhotos: Array<{latitude: string, longitude: string, iconUrl}> = []; + mapCenter = {latitude: "0", longitude: "0"}; + + @ViewChild("root") elementRef: ElementRef; + + @ViewChild(SebmGoogleMap) map: SebmGoogleMap; + + + constructor(private fullScreenService: FullScreenService) { + + + } + +//TODO: fix zooming + ngOnChanges() { + this.mapPhotos = this.photos.filter(p => { + return p.metadata && p.metadata.positionData && p.metadata.positionData.GPSData; + }).map(p => { + return { + latitude: p.metadata.positionData.GPSData.latitude, + longitude: p.metadata.positionData.GPSData.longitude, + iconUrl: Utils.concatUrls("/api/gallery/content/", p.directory.path, p.directory.name, p.name, "icon") + }; + }); + + if (this.mapPhotos.length > 0) { + this.mapCenter = this.mapPhotos[0]; + } + + + } + + public show(position: Dimension) { + this.visible = true; + this.opacity = 1.0; + this.startPosition = position; + this.lightboxDimension = position; + this.lightboxDimension.top -= this.getBodyScrollTop(); + this.mapDimension = { + top: 0, + left: 0, + width: this.getScreenWidth(), + height: this.getScreenHeight() + }; + this.map.triggerResize(); + + document.getElementsByTagName('body')[0].style.overflow = 'hidden'; + + setImmediate(() => { + this.lightboxDimension = { + top: 0, + left: 0, + width: this.getScreenWidth(), + height: this.getScreenHeight() + }; + }); + } + + public hide() { + this.fullScreenService.exitFullScreen(); + let to = this.startPosition; + + //iff target image out of screen -> scroll to there + if (this.getBodyScrollTop() > to.top || this.getBodyScrollTop() + this.getScreenHeight() < to.top) { + this.setBodyScrollTop(to.top); + } + + this.lightboxDimension = this.startPosition; + this.lightboxDimension.top -= this.getBodyScrollTop(); + document.getElementsByTagName('body')[0].style.overflow = 'scroll'; + this.opacity = 0.0; + setTimeout(() => { + this.visible = false; + }, 500); + + + } + + + private getBodyScrollTop(): number { + return window.scrollY; + } + + private setBodyScrollTop(value: number) { + window.scrollTo(window.scrollX, value); + } + + private getScreenWidth() { + return window.innerWidth; + } + + private getScreenHeight() { + return window.innerHeight; + } + + +} + diff --git a/frontend/app/gallery/map/map.gallery.component.css b/frontend/app/gallery/map/map.gallery.component.css index 3e97a28b..ee9b3379 100644 --- a/frontend/app/gallery/map/map.gallery.component.css +++ b/frontend/app/gallery/map/map.gallery.component.css @@ -1,4 +1,10 @@ .sebm-google-map-container { + width: 100%; + height: 100%; +} + +#map { + width: 100%; height: 100%; } \ No newline at end of file diff --git a/frontend/app/gallery/map/map.gallery.component.html b/frontend/app/gallery/map/map.gallery.component.html index 504ceed2..cf134acf 100644 --- a/frontend/app/gallery/map/map.gallery.component.html +++ b/frontend/app/gallery/map/map.gallery.component.html @@ -1,15 +1,19 @@ + +
+ [longitude]="photo.longitude"> - \ No newline at end of file + +
\ No newline at end of file diff --git a/frontend/app/gallery/map/map.gallery.component.ts b/frontend/app/gallery/map/map.gallery.component.ts index 356600db..6c6a8deb 100644 --- a/frontend/app/gallery/map/map.gallery.component.ts +++ b/frontend/app/gallery/map/map.gallery.component.ts @@ -1,17 +1,21 @@ -import {Component, OnChanges, Input} from "@angular/core"; +import {Component, OnChanges, Input, ViewChild, ElementRef} from "@angular/core"; import {PhotoDTO} from "../../../../common/entities/PhotoDTO"; import {Utils} from "../../../../common/Utils"; +import {IRenderable, Dimension} from "../../model/IRenderable"; +import {GalleryMapLightboxComponent} from "./lightbox/lightbox.map.gallery.component"; @Component({ selector: 'gallery-map', templateUrl: 'app/gallery/map/map.gallery.component.html', styleUrls: ['app/gallery/map/map.gallery.component.css'] }) -export class GalleryMapComponent implements OnChanges { +export class GalleryMapComponent implements OnChanges, IRenderable { @Input() photos: Array; + @ViewChild(GalleryMapLightboxComponent) mapLightbox: GalleryMapLightboxComponent; mapPhotos: Array<{latitude: string, longitude: string, iconUrl}> = []; mapCenter = {latitude: "0", longitude: "0"}; + @ViewChild("map") map: ElementRef; //TODO: fix zooming ngOnChanges() { @@ -31,5 +35,18 @@ export class GalleryMapComponent implements OnChanges { } + + click() { + this.mapLightbox.show(this.getDimension()); + } + + public getDimension(): Dimension { + return { + top: this.map.nativeElement.offsetTop, + left: this.map.nativeElement.offsetLeft, + width: this.map.nativeElement.offsetWidth, + height: this.map.nativeElement.offsetHeight + }; + } }