From cc8f4383eb64fe0e032ca9365e5fecb5fbbfab8f Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 26 May 2018 21:47:39 -0400 Subject: [PATCH] improving map lightbox --- .../lightbox/lightbox.map.gallery.component.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts index 81e75a0..eecfc6c 100644 --- a/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts +++ b/frontend/app/gallery/map/lightbox/lightbox.map.gallery.component.ts @@ -47,7 +47,7 @@ export class GalleryMapLightboxComponent implements OnChanges { this.opacity = 1.0; this.startPosition = position; this.lightboxDimension = position; - this.lightboxDimension.top -= this.getBodyScrollTop(); + this.lightboxDimension.top -= PageHelper.ScrollY; this.mapDimension = { top: 0, left: 0, @@ -74,12 +74,12 @@ export class GalleryMapLightboxComponent implements OnChanges { const 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); + if (PageHelper.ScrollY > to.top || PageHelper.ScrollY + this.getScreenHeight() < to.top) { + PageHelper.ScrollY = to.top; } this.lightboxDimension = this.startPosition; - this.lightboxDimension.top -= this.getBodyScrollTop(); + this.lightboxDimension.top -= PageHelper.ScrollY; PageHelper.showScrollY(); this.opacity = 0.0; setTimeout(() => { @@ -145,14 +145,6 @@ export class GalleryMapLightboxComponent implements OnChanges { } - private getBodyScrollTop(): number { - return window.scrollY; - } - - private setBodyScrollTop(value: number) { - window.scrollTo(window.scrollX, value); - } - private getScreenWidth() { return window.innerWidth; }