+
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/src/app/carousel/carousel.component.scss b/src/app/carousel/carousel.component.scss
index 18de85d..0f2615c 100644
--- a/src/app/carousel/carousel.component.scss
+++ b/src/app/carousel/carousel.component.scss
@@ -14,19 +14,30 @@
grid-template-rows: 1;
}
-.controls {
- position: absolute;
- top: 10%;
+.slide-vertical {
+ background-color: green;
+ grid-template-columns: 1;
+
}
+
+
.window {
- transition: 1s;
display: grid;
- grid-template-columns: repeat(3, 1fr);
- grid-auto-flow: column;
width: 100%;
+ height: 100%;
}
+// .window {
+// grid-template-columns: repeat(3, 1fr);
+// grid-auto-flow: column;
+// }
+
+// .window-vertical {
+// grid-template-rows: repeat(3, 1fr);
+// grid-auto-flow: row;
+// }
+
.current {
background-color: magenta;
}
diff --git a/src/app/carousel/carousel.component.ts b/src/app/carousel/carousel.component.ts
index caab034..fd4b18d 100644
--- a/src/app/carousel/carousel.component.ts
+++ b/src/app/carousel/carousel.component.ts
@@ -1,3 +1,5 @@
+import { animate, keyframes, state, style, transition, trigger } from '@angular/animations';
+import { NgStyle } from '@angular/common';
import { AfterViewInit, ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, TemplateRef, ViewChild, ViewChildren } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Subject, debounceTime } from 'rxjs';
@@ -11,6 +13,23 @@ import { Subject, debounceTime } from 'rxjs';
BrowserModule
],
animations: [
+ trigger('direction', [
+ state('vertical', style({
+ 'grid-auto-flow': 'row',
+ })),
+ state('horizontal', style({
+ 'grid-auto-flow': 'column',
+ })),
+ state('hidden', style({
+ opacity: 0,
+ })),
+ state('unhidden', style({
+ opacity: 1,
+ })),
+ transition('* => hidden', animate(`{{directionTime}}ms`)),
+ transition('hidden => unhidden', animate(`{{directionTime}}ms`)),
+ transition('unhidden => *', animate(0)),
+ ])
]
})
export class CarouselComponent implements OnInit, AfterViewInit {
@@ -27,6 +46,10 @@ export class CarouselComponent implements OnInit, AfterViewInit {
intersectionObserver?: IntersectionObserver;
visibleSlides?: IntersectingSlide[];
increasing: boolean = true;
+ vertical: boolean = true;
+ angularAnimating: boolean = false;
+ animation: string = 'vertical';
+ directionTime: number = 0;
private debouncedOnchange: Subject
= new Subject();
@@ -141,7 +164,6 @@ export class CarouselComponent implements OnInit, AfterViewInit {
{
const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index);
const lowestIntersecting = intersecting![0];
- console.log("lowest intersecting: ", lowestIntersecting?.index);
this.visibleSlides = this.visibleSlides?.filter(e => e.index + 2 >= lowestIntersecting!.index && e.index >= this.current - 2);
}
@@ -149,47 +171,71 @@ export class CarouselComponent implements OnInit, AfterViewInit {
const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index).reverse();
const highestIntersecting = intersecting![0]
- console.log("highest intersecting: ", highestIntersecting?.index);
this.visibleSlides = this.visibleSlides?.filter(e => e.index - 2 <= highestIntersecting!.index && e.index <= this.current + 2);
}
}
translation() {
let num = (this.current - 1) * (-1 / 3) * 100;
- return `${num}% 0`
+ if (this.vertical) {
+ return `0 ${num}%`
+ } else {
+ return `${num}% 0`
+ }
}
- left(index: number) {
- if (this.window.nativeElement) {
- const width = this.window.nativeElement.clientWidth;
- const slideWidth = width / 3.0;
- const slideLeft = Math.round(index * slideWidth);
- return `${slideLeft}px !important`;
- }
- return 0;
- // let num = (index) * 33.333333;
- // return `${num}%`
+ templateValue() {
+ const len = this.slides?.length;
+ return `repeat(${len}, minmax(calc(100% / 3), 1fr))`;
}
+ // .window {
+ // grid-template-columns: repeat(3, 1fr);
+ // grid-auto-flow: column;
+ // }
+
+ // .window-vertical {
+ // grid-template-rows: repeat(3, 1fr);
+ // grid-auto-flow: row;
+ // }
+ style() {
+ let style: any = {
+
+ };
+
+ if (this.vertical) {
+ style['grid-template-rows'] = this.templateValue();
+ } else {
+ style['grid-template-columns'] = this.templateValue();
+ }
+
+ if (!this.angularAnimating) {
+ style.transition = '500ms';
+ }
- width(index: number) {
- if (this.window.nativeElement) {
- const width = this.window.nativeElement.clientWidth;
- const slideWidth = Math.round(width / 3.0);
+ return style;
+ }
- return `${slideWidth}px !important`;
- }
+ onAnimationEnd(event: any) {
+ if (event.toState == 'hidden') {
+ this.vertical = !this.vertical;
+ this.animation = 'unhidden';
+ }
+ else if (event.toState == 'unhidden') {
+ this.animation = this.vertical ? 'vertical' : 'horizontal';
+ } else {
+ this.angularAnimating = false;
+ }
+ }
- let num = 33.33333333;
- return `${num}% !important`
-
+ onAnimationStart(event: any) {
+ this.angularAnimating = true;
}
- templateColumns() {
- const len = this.slides?.length;
- const value = `repeat(${len}, minmax(calc(100% / 3), 1fr))`;
- return value;
+ changeDirection() {
+ this.animation = 'hidden';
}
+
}
interface IntersectingSlide {
diff --git a/src/app/plan-display/plan-display.component.html b/src/app/plan-display/plan-display.component.html
index e4ef28a..0a29856 100644
--- a/src/app/plan-display/plan-display.component.html
+++ b/src/app/plan-display/plan-display.component.html
@@ -4,7 +4,7 @@
#targetRef>
-
+
{{slide}}
@@ -13,6 +13,16 @@
\ No newline at end of file
diff --git a/src/app/plan-display/plan-display.component.scss b/src/app/plan-display/plan-display.component.scss
index d610e61..e810a23 100644
--- a/src/app/plan-display/plan-display.component.scss
+++ b/src/app/plan-display/plan-display.component.scss
@@ -10,4 +10,9 @@
& > * {
flex: 1 1 auto;
}
+}
+
+.controls {
+ position: absolute;
+ top: 0;
}
\ No newline at end of file
diff --git a/src/app/plan-display/plan-display.module.ts b/src/app/plan-display/plan-display.module.ts
index 100b59d..efe7752 100644
--- a/src/app/plan-display/plan-display.module.ts
+++ b/src/app/plan-display/plan-display.module.ts
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import { NgxMoveableComponent } from 'ngx-moveable';
import { PlanDisplayComponent } from './plan-display.component';
import { CarouselComponent } from '../carousel/carousel.component';
+import { FormsModule } from '@angular/forms';
@NgModule({
@@ -12,7 +13,8 @@ import { CarouselComponent } from '../carousel/carousel.component';
imports: [
CommonModule,
NgxMoveableComponent,
- CarouselComponent
+ CarouselComponent,
+ FormsModule
],
exports: [
PlanDisplayComponent