minor fixes and cleanup

master
Константин 2023-12-11 18:24:35 +03:00
parent deacbcccdd
commit 58ad203783
2 changed files with 2 additions and 56 deletions

View File

@ -1,8 +1,6 @@
import {Component, Input} from '@angular/core';
import {ObjectsService} from "@app/_services";
import SwiperCore, {Navigation, Pagination, SwiperOptions} from 'swiper';
import {GalleryService} from "@app/_services/gallery.service";
SwiperCore.use([Navigation, Pagination]);
@Component({
selector: 'images-section',
@ -12,32 +10,11 @@ SwiperCore.use([Navigation, Pagination]);
export class ImagesSectionComponent {
@Input() section: any;
public config: SwiperOptions = {
slidesPerView: 1,
spaceBetween: 50
};
public parsedPhotos: any[] = []
public activePhoto: string = ''
public nextId:string;
public backId:string;
public showId: string = ''
public showFullscreen = false;
public activeIndex: number = 0
public tmpNumber: number = 0
constructor(private objectsService: ObjectsService, private galleryService: GalleryService) {
}
ngOnInit() {
this.config.navigation = {
prevEl: `#section-${this.section?.id} .prev`, nextEl: `#section-${this.section?.id} .next`
}
setTimeout(()=>{
this.parsed();
}, 300)
}
get items() {
@ -48,37 +25,6 @@ export class ImagesSectionComponent {
return type.name;
}
set photo(activePhoto: string) {
this.activePhoto = activePhoto
}
get photo(): string {
return this.activePhoto
}
parsed(): void {
this.tmpNumber = 0
this.parsedPhotos = this.items || []
this.parsedPhotos.map((photo: any) => {
if (this.tmpNumber===0) {
photo.active = true
this.photo = photo.links.full
this.showId = photo.id
} else {
photo.active = false
if (this.tmpNumber===1) {
this.nextId = photo.id
}
}
this.tmpNumber++
if (this.items.length > 1 && this.items.length == this.tmpNumber) {
this.backId = photo.id
}
return photo
})
}
show(i:number): void {
this.galleryService.show(this.items, i);

View File

@ -3,8 +3,8 @@ import {BehaviorSubject} from 'rxjs';
@Injectable({providedIn: 'root'})
export class GalleryService {
public imagesSubject = new BehaviorSubject(null);
public positionSubject = new BehaviorSubject(null);
public imagesSubject = new BehaviorSubject<any>(null);
public positionSubject = new BehaviorSubject<any>(null);
constructor() {
}