* user selection disabled
* animations added * history handling fixed
This commit is contained in:
parent
32c5bb4bb6
commit
2e6980e8c9
@ -19,6 +19,7 @@
|
|||||||
"testTsconfig": "tsconfig.spec.json",
|
"testTsconfig": "tsconfig.spec.json",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"styles": [
|
"styles": [
|
||||||
|
"../node_modules/normalize.css/normalize.css",
|
||||||
"assets/css/font-awesome.css",
|
"assets/css/font-awesome.css",
|
||||||
"styles.css"
|
"styles.css"
|
||||||
],
|
],
|
||||||
@ -41,6 +42,7 @@
|
|||||||
"tsconfig": "tsconfig.app-ssr.json",
|
"tsconfig": "tsconfig.app-ssr.json",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"styles": [
|
"styles": [
|
||||||
|
"../node_modules/normalize.css/normalize.css",
|
||||||
"assets/css/font-awesome.css",
|
"assets/css/font-awesome.css",
|
||||||
"styles.css"
|
"styles.css"
|
||||||
],
|
],
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@ -5273,6 +5273,11 @@
|
|||||||
"sort-keys": "1.1.2"
|
"sort-keys": "1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"normalize.css": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/normalize.css/-/normalize.css-7.0.0.tgz",
|
||||||
|
"integrity": "sha1-q/sd2CRwZ04DIrU86xqvQSk45L8="
|
||||||
|
},
|
||||||
"npm-run-path": {
|
"npm-run-path": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
"@angular/platform-server": "^4.3.3",
|
"@angular/platform-server": "^4.3.3",
|
||||||
"@angular/router": "^4.2.4",
|
"@angular/router": "^4.2.4",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
|
"normalize.css": "^7.0.0",
|
||||||
"pm2": "^2.6.1",
|
"pm2": "^2.6.1",
|
||||||
"rxjs": "^5.4.2",
|
"rxjs": "^5.4.2",
|
||||||
"zone.js": "^0.8.14"
|
"zone.js": "^0.8.14"
|
||||||
|
|||||||
14
src/app/animations/fade-in.animation.ts
Normal file
14
src/app/animations/fade-in.animation.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {trigger, state, animate, transition, style} from '@angular/animations';
|
||||||
|
|
||||||
|
export const fadeInAnimation =
|
||||||
|
trigger('fadeInAnimation', [
|
||||||
|
// route 'enter' transition
|
||||||
|
transition(':enter', [
|
||||||
|
|
||||||
|
// styles at start of transition
|
||||||
|
style({opacity: 0}),
|
||||||
|
|
||||||
|
// animation and styles at end of transition
|
||||||
|
animate('3s', style({opacity: 1}))
|
||||||
|
]),
|
||||||
|
]);
|
||||||
2
src/app/animations/index.ts
Normal file
2
src/app/animations/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './fade-in.animation';
|
||||||
|
export * from './slide-in-out.animation';
|
||||||
51
src/app/animations/slide-in-out.animation.ts
Normal file
51
src/app/animations/slide-in-out.animation.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import {trigger, state, animate, transition, style} from '@angular/animations';
|
||||||
|
|
||||||
|
export const slideInOutAnimation =
|
||||||
|
trigger('slideInOutAnimation', [
|
||||||
|
|
||||||
|
// end state styles for route container (host)
|
||||||
|
state('*', style({
|
||||||
|
// the view covers the whole screen with a semi tranparent background
|
||||||
|
position: 'fixed',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
// backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||||
|
})),
|
||||||
|
|
||||||
|
// route 'enter' transition
|
||||||
|
transition(':enter', [
|
||||||
|
|
||||||
|
// styles at start of transition
|
||||||
|
style({
|
||||||
|
// start with the content positioned off the right of the screen,
|
||||||
|
// -400% is required instead of -100% because the negative position adds to the width of the element
|
||||||
|
top: '-100%',
|
||||||
|
|
||||||
|
// start with background opacity set to 0 (invisible)
|
||||||
|
// backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||||
|
}),
|
||||||
|
|
||||||
|
// animation and styles at end of transition
|
||||||
|
animate('.5s ease-in-out', style({
|
||||||
|
// transition the right position to 0 which slides the content into view
|
||||||
|
top: 0,
|
||||||
|
|
||||||
|
// transition the background opacity to 0.8 to fade it in
|
||||||
|
// backgroundColor: 'rgba(0, 0, 0, 0.8)'
|
||||||
|
}))
|
||||||
|
]),
|
||||||
|
|
||||||
|
// route 'leave' transition
|
||||||
|
transition(':leave', [
|
||||||
|
// animation and styles at end of transition
|
||||||
|
animate('.5s ease-in-out', style({
|
||||||
|
// transition the right position to -400% which slides the content out of view
|
||||||
|
top: '-100%',
|
||||||
|
|
||||||
|
// transition the background opacity to 0 to fade it out
|
||||||
|
// backgroundColor: 'rgba(0, 0, 0, 0)'
|
||||||
|
}))
|
||||||
|
])
|
||||||
|
]);
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
@ -13,6 +14,7 @@ import { GalleryModule } from "./gallery/gallery.module";
|
|||||||
BrowserModule.withServerTransition({
|
BrowserModule.withServerTransition({
|
||||||
appId: 'angullary'
|
appId: 'angullary'
|
||||||
}),
|
}),
|
||||||
|
BrowserAnimationsModule,
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
GalleryModule,
|
GalleryModule,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import {Title} from "@angular/platform-browser";
|
import { Title } from "@angular/platform-browser";
|
||||||
|
|
||||||
import {Album} from "../shared/album.model";
|
import { Album } from "../shared/album.model";
|
||||||
import {DisplayImageService} from "../display-image/display-image.service";
|
import { DisplayImageService } from "../display-image/display-image.service";
|
||||||
import {environment} from "../../../environments/environment";
|
import { environment } from "../../../environments/environment";
|
||||||
import {Image} from "../shared/image.model";
|
import { Image } from "../shared/image.model";
|
||||||
import {Thumbnail} from "../shared/thumbnail.model";
|
import { Thumbnail } from "../shared/thumbnail.model";
|
||||||
|
|
||||||
const IDX_LEFT = 0;
|
const IDX_LEFT = 0;
|
||||||
const IDX_MIDDLE = 1;
|
const IDX_MIDDLE = 1;
|
||||||
@ -32,20 +32,26 @@ export class AlbumComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private titleService: Title,
|
constructor(private titleService: Title,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private displayImageService: DisplayImageService) {}
|
private displayImageService: DisplayImageService) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.data.subscribe((data: { albums: Array<Album>}) => {
|
this.route.data.subscribe((data: { albums: Array<Album> }) => {
|
||||||
this.album = data.albums.find(album => album.slug == this.route.snapshot.params.slug);
|
this.album = data.albums.find(album => album.slug == this.route.snapshot.params.slug);
|
||||||
this.titleService.setTitle(`${this.album.name} - photos.yvan.hu`);
|
this.titleService.setTitle(`${this.album.name} - photos.yvan.hu`);
|
||||||
this.initThumbnails();
|
this.initThumbnails();
|
||||||
if(this.route.snapshot.params.image) {
|
this.route.params.subscribe((params: {
|
||||||
|
slug: string,
|
||||||
|
image: string
|
||||||
|
}) => {
|
||||||
|
if (params.image) {
|
||||||
this.imageClick(
|
this.imageClick(
|
||||||
this.route.snapshot.params.slug,
|
params.slug,
|
||||||
this.route.snapshot.params.image
|
params.image
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private initThumbnails() {
|
private initThumbnails() {
|
||||||
@ -62,7 +68,7 @@ export class AlbumComponent implements OnInit {
|
|||||||
}).map(thumbnail => {
|
}).map(thumbnail => {
|
||||||
let heights = [this.leftHeight, this.middleHeight, this.rightHeight];
|
let heights = [this.leftHeight, this.middleHeight, this.rightHeight];
|
||||||
let idx = heights.reduce((low, nxt, idx) => nxt < heights[low] ? idx : low, 0);
|
let idx = heights.reduce((low, nxt, idx) => nxt < heights[low] ? idx : low, 0);
|
||||||
switch(idx) {
|
switch (idx) {
|
||||||
case IDX_LEFT:
|
case IDX_LEFT:
|
||||||
this.thumbnailsLeft.push(thumbnail);
|
this.thumbnailsLeft.push(thumbnail);
|
||||||
this.leftHeight += thumbnail.height + THUMB_MARGIN;
|
this.leftHeight += thumbnail.height + THUMB_MARGIN;
|
||||||
@ -91,7 +97,7 @@ export class AlbumComponent implements OnInit {
|
|||||||
this.displayImageService.activate(slug, path, this.album.name);
|
this.displayImageService.activate(slug, path, this.album.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public switchImage(evnt:{direction: string, currentPath: string}) {
|
public switchImage(evnt: { direction: string, currentPath: string }) {
|
||||||
switch (evnt.direction) {
|
switch (evnt.direction) {
|
||||||
case 'next':
|
case 'next':
|
||||||
this.nextImage(evnt.currentPath);
|
this.nextImage(evnt.currentPath);
|
||||||
@ -104,20 +110,20 @@ export class AlbumComponent implements OnInit {
|
|||||||
|
|
||||||
private nextImage(path: string) {
|
private nextImage(path: string) {
|
||||||
let currentIndex: number = this.album.images.findIndex(image => image.path == path);
|
let currentIndex: number = this.album.images.findIndex(image => image.path == path);
|
||||||
if(this.album.images.length-1 > currentIndex) {
|
if (this.album.images.length - 1 > currentIndex) {
|
||||||
this.displayImageService.activate(
|
this.displayImageService.activate(
|
||||||
this.album.slug,
|
this.album.slug,
|
||||||
this.album.images[currentIndex+1].path
|
this.album.images[currentIndex + 1].path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private prevImage(path: string) {
|
private prevImage(path: string) {
|
||||||
let currentIndex: number = this.album.images.findIndex(image => image.path == path);
|
let currentIndex: number = this.album.images.findIndex(image => image.path == path);
|
||||||
if(0 < currentIndex) {
|
if (0 < currentIndex) {
|
||||||
this.displayImageService.activate(
|
this.displayImageService.activate(
|
||||||
this.album.slug,
|
this.album.slug,
|
||||||
this.album.images[currentIndex-1].path
|
this.album.images[currentIndex - 1].path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { Location } from "@angular/common";
|
|||||||
import { environment } from "../../../environments/environment";
|
import { environment } from "../../../environments/environment";
|
||||||
import { Title } from "@angular/platform-browser";
|
import { Title } from "@angular/platform-browser";
|
||||||
import { DisplayImageService } from "./display-image.service";
|
import { DisplayImageService } from "./display-image.service";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-display-image',
|
selector: 'app-display-image',
|
||||||
@ -24,12 +25,13 @@ export class DisplayImageComponent implements OnInit {
|
|||||||
private visible: boolean = false;
|
private visible: boolean = false;
|
||||||
|
|
||||||
public constructor(private titleService: Title,
|
public constructor(private titleService: Title,
|
||||||
private locationService: Location,
|
private router: Router,
|
||||||
private displayImageService: DisplayImageService) {
|
private displayImageService: DisplayImageService) {
|
||||||
displayImageService.activate = this.activate.bind(this);
|
displayImageService.activate = this.activate.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {}
|
public ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
public get modalStyle(): any {
|
public get modalStyle(): any {
|
||||||
return {
|
return {
|
||||||
@ -43,17 +45,14 @@ export class DisplayImageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get imageUrl(): string {
|
public get imageUrl(): string {
|
||||||
try {
|
let url = environment.apiUrl + `/image/${this.slug}/${this.image}`;
|
||||||
return environment.apiUrl + `/image/${this.slug}/${this.image}`;
|
return url;
|
||||||
} catch (e) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public activate(slug = "", image = "", extitle = "") {
|
public activate(slug = "", image = "", extitle = "") {
|
||||||
this.init(slug, image, extitle);
|
this.init(slug, image, extitle);
|
||||||
|
|
||||||
this.locationService.go(`/album/${this.slug}/${this.image}`);
|
this.router.navigate([`/album/${this.slug}/${this.image}`]);
|
||||||
|
|
||||||
return new Promise<boolean>(resolve => {
|
return new Promise<boolean>(resolve => {
|
||||||
this.show(resolve);
|
this.show(resolve);
|
||||||
@ -76,7 +75,7 @@ export class DisplayImageComponent implements OnInit {
|
|||||||
private hide() {
|
private hide() {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.titleService.setTitle(`${this.albumTitle} - photos.yvan.hu`);
|
this.titleService.setTitle(`${this.albumTitle} - photos.yvan.hu`);
|
||||||
this.locationService.go(`/album/${this.slug}`);
|
this.router.navigate([`${this.albumTitle} - photos.yvan.hu`]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private nextImage() {
|
private nextImage() {
|
||||||
@ -114,7 +113,7 @@ export class DisplayImageComponent implements OnInit {
|
|||||||
|
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
private handleClick() {
|
private handleClick() {
|
||||||
if(this.visible) {
|
if (this.visible) {
|
||||||
this.nextImage();
|
this.nextImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,8 +129,8 @@ export class DisplayImageComponent implements OnInit {
|
|||||||
let xDiff: number = this.touchX - touchEvent.changedTouches[0].clientX;
|
let xDiff: number = this.touchX - touchEvent.changedTouches[0].clientX;
|
||||||
let yDiff: number = this.touchY - touchEvent.changedTouches[0].clientY;
|
let yDiff: number = this.touchY - touchEvent.changedTouches[0].clientY;
|
||||||
|
|
||||||
if( Math.abs(xDiff) > Math.abs(yDiff) ) {
|
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
||||||
if( xDiff>0 ) {
|
if (xDiff > 0) {
|
||||||
this.prevImage();
|
this.prevImage();
|
||||||
} else {
|
} else {
|
||||||
this.nextImage();
|
this.nextImage();
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@ -5,5 +5,6 @@
|
|||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'http://localhost:8888',
|
// apiUrl: 'http://localhost:8888',
|
||||||
|
apiUrl: 'http://photos-api.yvan.hu',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,25 +1,10 @@
|
|||||||
/* You can add global styles to this file, and also import other style files */
|
/* You can add global styles to this file, and also import other style files */
|
||||||
@import url('https://fonts.googleapis.com/css?family=Source Sans Pro:400,700,400italic,700italic&subset=latin');
|
@import url('https://fonts.googleapis.com/css?family=Source Sans Pro:400,700,400italic,700italic&subset=latin');
|
||||||
|
|
||||||
*,
|
/*html,*/
|
||||||
*:before,
|
/*body {*/
|
||||||
*:after {
|
/*height: 100%;*/
|
||||||
box-sizing: inherit;
|
/*}*/
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
|
||||||
body {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -31,6 +16,7 @@ body {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.4285em;
|
line-height: 1.4285em;
|
||||||
color: #839496;
|
color: #839496;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user