2020-06-16 19:07:32 +02:00
|
|
|
import {AfterContentInit, Component, ContentChildren, Input, OnInit, QueryList} from "@angular/core";
|
2020-06-15 21:02:44 +02:00
|
|
|
import {SlideComponent} from "./slide.component";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'fp-slider',
|
|
|
|
template: `
|
2020-06-16 21:59:51 +02:00
|
|
|
<div class="menu">
|
|
|
|
<img class="logo" *ngIf="logoURL" [src]="logoURL">
|
|
|
|
<a *ngIf="state > 1" class="previous" (click)="onClick(state - 1)">
|
2020-06-17 16:31:31 +02:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="17.155" height="17.155" viewBox="0 0 17.155 17.155">
|
|
|
|
<g id="Group_3053" data-name="Group 3053" transform="translate(0)">
|
|
|
|
<path id="arrow-down-left2"
|
|
|
|
d="M10.405,11.834,2.022,3.451V7.076A1.011,1.011,0,0,1,0,7.076V1.011A1.009,1.009,0,0,1,1.011,0H7.076a1.011,1.011,0,1,1,0,2.022H3.451l8.383,8.383a1.011,1.011,0,1,1-1.429,1.429h0Z"
|
|
|
|
transform="translate(8.578 0) rotate(45)" fill="#e95420"/>
|
|
|
|
</g>
|
|
|
|
</svg>
|
2020-06-16 21:59:51 +02:00
|
|
|
</a>
|
|
|
|
<nav>
|
|
|
|
<ul>
|
|
|
|
<li *ngFor="let slide of slides.toArray();let i=index" [class.uk-active]="i === (state - 1)">
|
|
|
|
<a (click)="onClick(i + 1)"></a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<a *ngIf="state < slides.length" class="next" (click)="onClick(state + 1)">
|
2020-06-17 16:31:31 +02:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="17.155" height="17.155" viewBox="0 0 17.155 17.155">
|
|
|
|
<g id="Group_2442" data-name="Group 2442" transform="translate(-1221 -675)">
|
|
|
|
<path id="arrow-down-left2"
|
|
|
|
d="M14.405,4.3,6.022,12.68V9.055A1.011,1.011,0,0,0,4,9.055V15.12a1.009,1.009,0,0,0,1.011,1.01h6.065a1.011,1.011,0,1,0,0-2.022H7.451l8.383-8.383A1.011,1.011,0,0,0,14.405,4.3h0Z"
|
|
|
|
transform="translate(1215.343 683.578) rotate(-45)" fill="#e95420"/>
|
|
|
|
</g>
|
|
|
|
</svg>
|
2020-06-16 21:59:51 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
2020-06-15 21:02:44 +02:00
|
|
|
<section (wheel)="onWheel($event)">
|
2020-06-17 16:31:31 +02:00
|
|
|
<ng-content></ng-content>
|
2020-06-15 21:02:44 +02:00
|
|
|
</section>`,
|
|
|
|
styleUrls: ['full-page-slider.component.css']
|
|
|
|
})
|
|
|
|
export class FullPageSliderComponent implements AfterContentInit {
|
|
|
|
|
|
|
|
@ContentChildren(SlideComponent) slides: QueryList<SlideComponent>;
|
2020-06-16 19:07:32 +02:00
|
|
|
@Input()
|
|
|
|
public initSlide = 1;
|
2020-06-16 21:59:51 +02:00
|
|
|
@Input()
|
|
|
|
public logoURL;
|
2020-06-15 21:02:44 +02:00
|
|
|
public animate: boolean = false;
|
|
|
|
public state = 0;
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
2020-06-16 19:07:32 +02:00
|
|
|
this.state = this.initSlide;
|
|
|
|
this.setSlides(this.state);
|
2020-06-15 21:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setSlides(state = 1) {
|
|
|
|
this.slides.forEach((slide, index) => {
|
|
|
|
slide.state = state;
|
2020-06-17 16:31:31 +02:00
|
|
|
slide.y = -50 + (index + 1) * 200 - state * 200;
|
2020-06-15 21:02:44 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onWheel(event) {
|
|
|
|
if (!this.animate) {
|
|
|
|
this.animate = true;
|
|
|
|
if (event.deltaY > 0 && (this.state < this.slides.length)) {
|
|
|
|
this.state++;
|
|
|
|
this.setSlides(this.state);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animate = false;
|
2020-06-16 21:59:51 +02:00
|
|
|
}, 500);
|
2020-06-15 21:02:44 +02:00
|
|
|
} else if (event.deltaY < 0 && (this.state !== 1)) {
|
|
|
|
this.state--;
|
|
|
|
this.setSlides(this.state);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animate = false;
|
2020-06-16 21:59:51 +02:00
|
|
|
}, 500);
|
2020-06-15 21:02:44 +02:00
|
|
|
} else {
|
|
|
|
this.animate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-16 21:59:51 +02:00
|
|
|
|
|
|
|
public onClick(index: number) {
|
|
|
|
if (!this.animate) {
|
|
|
|
this.animate = true;
|
|
|
|
this.state = index;
|
|
|
|
this.setSlides(this.state);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.animate = false;
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
}
|
2020-06-15 21:02:44 +02:00
|
|
|
}
|