Decided on carousel implementation for the 'plan elements'. Still need 'content' section of current plan element
parent
cf88afca08
commit
ab35c9e667
@ -0,0 +1,14 @@
|
|||||||
|
<ng-container *ngIf="template && slides">
|
||||||
|
|
||||||
|
<div class="carousel">
|
||||||
|
<div class="window" [style.translate]="translation()">
|
||||||
|
<ng-container *ngFor="let slide of slides">
|
||||||
|
<div class="slide"><ng-container
|
||||||
|
*ngTemplateOutlet="template!; context: { $implicit: slide }"></ng-container></div>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button (click)="prev()"><=prev</button>
|
||||||
|
<button (click)="next()">next></button>
|
||||||
|
|
||||||
|
</ng-container>
|
@ -0,0 +1,32 @@
|
|||||||
|
:host {
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.carousel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide {
|
||||||
|
width: 33.333%;
|
||||||
|
min-width: 33.333%;
|
||||||
|
max-width: 33.333%;
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
width: 100%;
|
||||||
|
transition: 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.current {
|
||||||
|
background-color: magenta;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transparent {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
import { Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef } from '@angular/core';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'carousel',
|
||||||
|
templateUrl: './carousel.component.html',
|
||||||
|
styleUrls: ['./carousel.component.scss'],
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
BrowserModule
|
||||||
|
],
|
||||||
|
animations: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class CarouselComponent implements OnInit {
|
||||||
|
@Output() afterInitSelf: EventEmitter<CarouselComponent> = new EventEmitter<CarouselComponent>();
|
||||||
|
@Input() slides?: any[];
|
||||||
|
@ContentChild(TemplateRef) template?: TemplateRef<any>;
|
||||||
|
current: number = 0;
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.afterInitSelf.next(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
next(): void {
|
||||||
|
if (this.slides && this.current + 1 < this.slides?.length) {
|
||||||
|
console.log("incremented");
|
||||||
|
this.current += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prev(): void {
|
||||||
|
console.log("decremented");
|
||||||
|
if (this.current - 1 >= 0) {
|
||||||
|
this.current -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
translation() {
|
||||||
|
let num = (this.current - 1) * (-1/3) * 100;
|
||||||
|
return `${num}% 0`
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue