From 4883c290281bd2ca992187ec9941e8df4eaef937 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Sat, 15 Jul 2017 20:23:02 +0200 Subject: [PATCH] improving grid performance --- .../directory/directory.gallery.component.css | 50 +++++----- .../photo/photo.grid.gallery.component.css | 96 +++++++++---------- .../photo/photo.grid.gallery.component.html | 56 ++++++----- .../photo/photo.grid.gallery.component.ts | 35 +++++-- .../app/gallery/thumnailLoader.service.ts | 1 - 5 files changed, 128 insertions(+), 110 deletions(-) diff --git a/frontend/app/gallery/directory/directory.gallery.component.css b/frontend/app/gallery/directory/directory.gallery.component.css index 7d51b81f..0643b14d 100644 --- a/frontend/app/gallery/directory/directory.gallery.component.css +++ b/frontend/app/gallery/directory/directory.gallery.component.css @@ -1,53 +1,53 @@ a { - position: relative; + position: relative; } .photo-container { - border: 2px solid #333; + border: 2px solid #333; width: 180px; height: 180px; - - background-color: #bbbbbb; + background-color: #bbbbbb; } + .no-image { - color: #7f7f7f; - font-size: 50px; - top: calc(50% - 25px); - left: calc(50% - 25px); + color: #7f7f7f; + font-size: 50px; + top: calc(50% - 25px); + left: calc(50% - 25px); } .photo { - width: 100%; - height: 100%; - background-size: cover; - background-position: center; + width: 100%; + height: 100%; + background-size: cover; + background-position: center; } .button { - border: 0; - padding: 0; - text-align: left; + border: 0; + padding: 0; + text-align: left; } .info { - background-color: rgba(0, 0, 0, 0.6); - color: white; - font-size: medium; - position: absolute; - bottom: 0; - left: 0; - padding: 5px; - width: 100%; + background-color: rgba(0, 0, 0, 0.6); + color: white; + font-size: medium; + position: absolute; + bottom: 0; + left: 0; + padding: 5px; + width: 100%; } a:hover .info { - background-color: rgba(0, 0, 0, 0.8); + background-color: rgba(0, 0, 0, 0.8); } a:hover .photo-container { - border-color: #000; + border-color: #000; } .directory-name { diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.css b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.css index 81e62fc3..063cb484 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.css +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.css @@ -1,51 +1,51 @@ img { - width: inherit; - height: inherit; + width: inherit; + height: inherit; - -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */ - -moz-animation: fadein 2s; /* Firefox < 16 */ - -ms-animation: fadein 2s; /* Internet Explorer */ - -o-animation: fadein 2s; /* Opera < 12.1 */ - animation: fadein 2s; + -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */ + -moz-animation: fadein 2s; /* Firefox < 16 */ + -ms-animation: fadein 2s; /* Internet Explorer */ + -o-animation: fadein 2s; /* Opera < 12.1 */ + animation: fadein 2s; } @keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } /* Firefox < 16 */ @-moz-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } /* Safari, Chrome and Opera > 12.1 */ @-webkit-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } /* Internet Explorer */ @-ms-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } .info { @@ -54,38 +54,38 @@ img { font-size: medium; position: relative; padding: 5px; - margin-top: -50px; + margin-top: 0; - transition: all .3s ease-out; - -moz-transition: all .3s ease-out; - -webkit-transition: all .3s ease-out; - -o-transition: all .3s ease-out; + transition: margin .3s ease-out, background-color .3s ease-out; + -moz-transition: margin .3s ease-out, background-color .3s ease-out; + -webkit-transition: margin .3s ease-out, background-color .3s ease-out; + -o-transition: margin .3s ease-out, background-color .3s ease-out; } .photo-container { - width: inherit; - height: inherit; - overflow: hidden; + width: inherit; + height: inherit; + overflow: hidden; } .photo-name { - display: inline-block; + display: inline-block; } .photo-position { - display: inline-block; - float: right; + display: inline-block; + float: right; } a { - color: white; + color: white; } .photo-keywords { - margin-top: 5px; - font-size: small; - text-align: right; - display: inline-block; - width: 100%; + margin-top: 5px; + font-size: small; + text-align: right; + display: inline-block; + width: 100%; } diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html index e5d944eb..c6657868 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html @@ -1,33 +1,37 @@
- - + + - -
-
{{gridPhoto.photo.name}}
+ +
+
{{gridPhoto.photo.name}}
-
- - - - {{getPositionText()}} - - {{getPositionText()}} - -
- -
- - #{{keyword}} - #{{keyword}} - , - - -
+
+ + + + {{getPositionText()}} + + {{getPositionText()}} +
+ +
+ + #{{keyword}} + #{{keyword}} + , + + +
+
diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts index d0b09b50..9ac82b07 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts @@ -5,12 +5,12 @@ import {SearchTypes} from "../../../../../common/entities/AutoCompleteItem"; import {RouterLink} from "@angular/router"; import {Thumbnail, ThumbnailManagerService} from "../../thumnailManager.service"; import {Config} from "../../../../../common/config/public/Config"; - +import {AnimationBuilder} from "@angular/animations"; @Component({ selector: 'gallery-grid-photo', templateUrl: './photo.grid.gallery.component.html', styleUrls: ['./photo.grid.gallery.component.css'], - providers: [RouterLink], + providers: [RouterLink] }) export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { @Input() gridPhoto: GridPhoto; @@ -31,24 +31,26 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { }; */ - infoStyle = { - height: 0, + infoBar = { + marginTop: 0, + visible: false, background: "rgba(0,0,0,0.0)" }; + animationTimer = null; SearchTypes: any = []; searchEnabled: boolean = true; wasInView: boolean = null; - constructor(private thumbnailService: ThumbnailManagerService) { + constructor(private thumbnailService: ThumbnailManagerService, + private _animationBuilder: AnimationBuilder) { this.SearchTypes = SearchTypes; this.searchEnabled = Config.Client.Search.enabled; } ngOnInit() { this.thumbnail = this.thumbnailService.getThumbnail(this.gridPhoto); - } @@ -83,15 +85,28 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { this.gridPhoto.photo.metadata.positionData.country; } + hover() { - this.infoStyle.height = this.infoDiv.nativeElement.clientHeight; - this.infoStyle.background = "rgba(0,0,0,0.8)"; + this.infoBar.visible = true; + if (this.animationTimer != null) { + clearTimeout(this.animationTimer); + } + this.animationTimer = setTimeout(() => { + this.infoBar.marginTop = -this.infoDiv.nativeElement.clientHeight; + this.infoBar.background = "rgba(0,0,0,0.8)"; + }, 1); } mouseOut() { - this.infoStyle.height = 0; - this.infoStyle.background = "rgba(0,0,0,0.0)"; + this.infoBar.marginTop = 0; + this.infoBar.background = "rgba(0,0,0,0.0)"; + if (this.animationTimer != null) { + clearTimeout(this.animationTimer); + } + this.animationTimer = setTimeout(() => { + this.infoBar.visible = false; + }, 500); } diff --git a/frontend/app/gallery/thumnailLoader.service.ts b/frontend/app/gallery/thumnailLoader.service.ts index f429a8d6..9a5522d4 100644 --- a/frontend/app/gallery/thumnailLoader.service.ts +++ b/frontend/app/gallery/thumnailLoader.service.ts @@ -165,7 +165,6 @@ export class ThumbnailLoaderService { this.runningRequests++; task.taskEntities.forEach(te => te.listener.onStartedLoading()); task.inProgress = true; - console.log("loading", task.path); let curImg = new Image(); curImg.onload = () => {