1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

improving grid performance

This commit is contained in:
Braun Patrik 2017-07-15 20:23:02 +02:00
parent 5cf8320c5f
commit 4883c29028
5 changed files with 128 additions and 110 deletions

View File

@ -1,53 +1,53 @@
a { a {
position: relative; position: relative;
} }
.photo-container { .photo-container {
border: 2px solid #333; border: 2px solid #333;
width: 180px; width: 180px;
height: 180px; height: 180px;
background-color: #bbbbbb;
background-color: #bbbbbb;
} }
.no-image { .no-image {
color: #7f7f7f; color: #7f7f7f;
font-size: 50px; font-size: 50px;
top: calc(50% - 25px); top: calc(50% - 25px);
left: calc(50% - 25px); left: calc(50% - 25px);
} }
.photo { .photo {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }
.button { .button {
border: 0; border: 0;
padding: 0; padding: 0;
text-align: left; text-align: left;
} }
.info { .info {
background-color: rgba(0, 0, 0, 0.6); background-color: rgba(0, 0, 0, 0.6);
color: white; color: white;
font-size: medium; font-size: medium;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
padding: 5px; padding: 5px;
width: 100%; width: 100%;
} }
a:hover .info { a:hover .info {
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.8);
} }
a:hover .photo-container { a:hover .photo-container {
border-color: #000; border-color: #000;
} }
.directory-name { .directory-name {

View File

@ -1,51 +1,51 @@
img { img {
width: inherit; width: inherit;
height: inherit; height: inherit;
-webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */ -webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 2s; /* Firefox < 16 */ -moz-animation: fadein 2s; /* Firefox < 16 */
-ms-animation: fadein 2s; /* Internet Explorer */ -ms-animation: fadein 2s; /* Internet Explorer */
-o-animation: fadein 2s; /* Opera < 12.1 */ -o-animation: fadein 2s; /* Opera < 12.1 */
animation: fadein 2s; animation: fadein 2s;
} }
@keyframes fadein { @keyframes fadein {
from { from {
opacity: 0; opacity: 0;
} }
to { to {
opacity: 1; opacity: 1;
} }
} }
/* Firefox < 16 */ /* Firefox < 16 */
@-moz-keyframes fadein { @-moz-keyframes fadein {
from { from {
opacity: 0; opacity: 0;
} }
to { to {
opacity: 1; opacity: 1;
} }
} }
/* Safari, Chrome and Opera > 12.1 */ /* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein { @-webkit-keyframes fadein {
from { from {
opacity: 0; opacity: 0;
} }
to { to {
opacity: 1; opacity: 1;
} }
} }
/* Internet Explorer */ /* Internet Explorer */
@-ms-keyframes fadein { @-ms-keyframes fadein {
from { from {
opacity: 0; opacity: 0;
} }
to { to {
opacity: 1; opacity: 1;
} }
} }
.info { .info {
@ -54,38 +54,38 @@ img {
font-size: medium; font-size: medium;
position: relative; position: relative;
padding: 5px; padding: 5px;
margin-top: -50px; margin-top: 0;
transition: all .3s ease-out; transition: margin .3s ease-out, background-color .3s ease-out;
-moz-transition: all .3s ease-out; -moz-transition: margin .3s ease-out, background-color .3s ease-out;
-webkit-transition: all .3s ease-out; -webkit-transition: margin .3s ease-out, background-color .3s ease-out;
-o-transition: all .3s ease-out; -o-transition: margin .3s ease-out, background-color .3s ease-out;
} }
.photo-container { .photo-container {
width: inherit; width: inherit;
height: inherit; height: inherit;
overflow: hidden; overflow: hidden;
} }
.photo-name { .photo-name {
display: inline-block; display: inline-block;
} }
.photo-position { .photo-position {
display: inline-block; display: inline-block;
float: right; float: right;
} }
a { a {
color: white; color: white;
} }
.photo-keywords { .photo-keywords {
margin-top: 5px; margin-top: 5px;
font-size: small; font-size: small;
text-align: right; text-align: right;
display: inline-block; display: inline-block;
width: 100%; width: 100%;
} }

View File

@ -1,33 +1,37 @@
<div #photoContainer class="photo-container" (mouseover)="hover()" (mouseout)="mouseOut()"> <div #photoContainer class="photo-container" (mouseover)="hover()" (mouseout)="mouseOut()">
<img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available"> <img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available">
<gallery-grid-photo-loading [animate]="thumbnail.loading" *ngIf="!thumbnail.Available"> <gallery-grid-photo-loading
</gallery-grid-photo-loading> [animate]="thumbnail.loading"
*ngIf="!thumbnail.Available">
</gallery-grid-photo-loading>
<!--Info box --> <!--Info box -->
<div #info class="info" [style.margin-top.px]="-infoStyle.height" <div #info class="info"
[style.background]="infoStyle.background"> *ngIf="infoBar.visible"
<div class="photo-name">{{gridPhoto.photo.name}}</div> [style.margin-top.px]="infoBar.marginTop"
[style.background]="infoBar.background">
<div class="photo-name">{{gridPhoto.photo.name}}</div>
<div class="photo-position" *ngIf="gridPhoto.photo.metadata.positionData"> <div class="photo-position" *ngIf="gridPhoto.photo.metadata.positionData">
<span class="glyphicon glyphicon-map-marker"></span> <span class="glyphicon glyphicon-map-marker"></span>
<ng-template [ngIf]="getPositionText()"> <ng-template [ngIf]="getPositionText()">
<a [routerLink]="['/search', getPositionText(), {type:SearchTypes[SearchTypes.position]}]" <a [routerLink]="['/search', getPositionText(), {type:SearchTypes[SearchTypes.position]}]"
*ngIf="searchEnabled"> *ngIf="searchEnabled">
{{getPositionText()}} {{getPositionText()}}
</a> </a>
<span *ngIf="!searchEnabled">{{getPositionText()}}</span> <span *ngIf="!searchEnabled">{{getPositionText()}}</span>
</ng-template> </ng-template>
</div>
<div class="photo-keywords">
<ng-template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last">
<a *ngIf="searchEnabled"
[routerLink]="['/search', keyword, {type: SearchTypes[SearchTypes.keyword]}]">#{{keyword}}</a>
<span *ngIf="!searchEnabled">#{{keyword}}</span>
<ng-template [ngIf]="!last">,</ng-template>
</ng-template>
</div>
</div> </div>
<div class="photo-keywords">
<ng-template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last">
<a *ngIf="searchEnabled"
[routerLink]="['/search', keyword, {type: SearchTypes[SearchTypes.keyword]}]">#{{keyword}}</a>
<span *ngIf="!searchEnabled">#{{keyword}}</span>
<ng-template [ngIf]="!last">,</ng-template>
</ng-template>
</div>
</div>
</div> </div>

View File

@ -5,12 +5,12 @@ import {SearchTypes} from "../../../../../common/entities/AutoCompleteItem";
import {RouterLink} from "@angular/router"; import {RouterLink} from "@angular/router";
import {Thumbnail, ThumbnailManagerService} from "../../thumnailManager.service"; import {Thumbnail, ThumbnailManagerService} from "../../thumnailManager.service";
import {Config} from "../../../../../common/config/public/Config"; import {Config} from "../../../../../common/config/public/Config";
import {AnimationBuilder} from "@angular/animations";
@Component({ @Component({
selector: 'gallery-grid-photo', selector: 'gallery-grid-photo',
templateUrl: './photo.grid.gallery.component.html', templateUrl: './photo.grid.gallery.component.html',
styleUrls: ['./photo.grid.gallery.component.css'], styleUrls: ['./photo.grid.gallery.component.css'],
providers: [RouterLink], providers: [RouterLink]
}) })
export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy {
@Input() gridPhoto: GridPhoto; @Input() gridPhoto: GridPhoto;
@ -31,24 +31,26 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy {
}; };
*/ */
infoStyle = { infoBar = {
height: 0, marginTop: 0,
visible: false,
background: "rgba(0,0,0,0.0)" background: "rgba(0,0,0,0.0)"
}; };
animationTimer = null;
SearchTypes: any = []; SearchTypes: any = [];
searchEnabled: boolean = true; searchEnabled: boolean = true;
wasInView: boolean = null; wasInView: boolean = null;
constructor(private thumbnailService: ThumbnailManagerService) { constructor(private thumbnailService: ThumbnailManagerService,
private _animationBuilder: AnimationBuilder) {
this.SearchTypes = SearchTypes; this.SearchTypes = SearchTypes;
this.searchEnabled = Config.Client.Search.enabled; this.searchEnabled = Config.Client.Search.enabled;
} }
ngOnInit() { ngOnInit() {
this.thumbnail = this.thumbnailService.getThumbnail(this.gridPhoto); this.thumbnail = this.thumbnailService.getThumbnail(this.gridPhoto);
} }
@ -83,15 +85,28 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy {
this.gridPhoto.photo.metadata.positionData.country; this.gridPhoto.photo.metadata.positionData.country;
} }
hover() { hover() {
this.infoStyle.height = this.infoDiv.nativeElement.clientHeight; this.infoBar.visible = true;
this.infoStyle.background = "rgba(0,0,0,0.8)"; 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() { mouseOut() {
this.infoStyle.height = 0; this.infoBar.marginTop = 0;
this.infoStyle.background = "rgba(0,0,0,0.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);
} }

View File

@ -165,7 +165,6 @@ export class ThumbnailLoaderService {
this.runningRequests++; this.runningRequests++;
task.taskEntities.forEach(te => te.listener.onStartedLoading()); task.taskEntities.forEach(te => te.listener.onStartedLoading());
task.inProgress = true; task.inProgress = true;
console.log("loading", task.path);
let curImg = new Image(); let curImg = new Image();
curImg.onload = () => { curImg.onload = () => {