Fixed some plan loading init issues

merge-notes 1.1.1
isark 2 years ago
parent 02021aabe9
commit 70cdb6b3b0

@ -8,7 +8,7 @@
}, },
"package": { "package": {
"productName": "Nothing", "productName": "Nothing",
"version": "1.1.0" "version": "1.1.1"
}, },
"tauri": { "tauri": {
"systemTray": { "systemTray": {

@ -135,14 +135,21 @@ export class CarouselComponent<T> implements OnInit, AfterViewInit {
setIndex(slideIndex: number) { setIndex(slideIndex: number) {
this.current = slideIndex; this.current = slideIndex;
console.log("setIndex", slideIndex);
for (let i = Math.max(-this.numExtraPrev(), 0); i <= Math.min(this.numExtraNext(), this.slides!.length - 1); i++) { this.visibleSlides!.length = 0;
console.log("length", this.slides!.length);
for (let i = -this.numExtraPrev(); i <= this.numExtraNext(); i++) {
console.log("i, ", i);
if (this.current + i >= 0 && this.current + i < this.slides!.length) {
console.log("pushing", this.current + i);
this.visibleSlides?.push({ this.visibleSlides?.push({
index: this.current + i, index: this.current + i,
hasBeenVisible: false, hasBeenVisible: false,
currentlyIntersecting: false, currentlyIntersecting: false,
}); });
} }
}
this.onChange(); this.onChange();
} }
@ -192,17 +199,20 @@ export class CarouselComponent<T> implements OnInit, AfterViewInit {
const safetyFactor = this.numVisible == 1 ? 1 : 2; const safetyFactor = this.numVisible == 1 ? 1 : 2;
{ {
const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index); const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index);
if (intersecting && intersecting.length > 0) {
const lowestIntersecting = intersecting![0]; const lowestIntersecting = intersecting![0];
this.visibleSlides = this.visibleSlides?.filter(e => e.index + safetyFactor >= lowestIntersecting!.index && e.index >= this.current - this.numExtraPrev()); this.visibleSlides = this.visibleSlides?.filter(e => e.index + safetyFactor >= lowestIntersecting!.index && e.index >= this.current - this.numExtraPrev());
}
} }
{ {
const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index).reverse(); const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index).reverse();
if (intersecting && intersecting.length > 0) {
const highestIntersecting = intersecting![0] const highestIntersecting = intersecting![0]
this.visibleSlides = this.visibleSlides?.filter(e => e.index - safetyFactor <= highestIntersecting!.index && e.index <= this.current + this.numExtraNext()); this.visibleSlides = this.visibleSlides?.filter(e => e.index - safetyFactor <= highestIntersecting!.index && e.index <= this.current + this.numExtraNext());
} }
} }
}
translation() { translation() {
let num = (this.current - this.numExtraNext() - (this.numVisible % 2 == 0 ? 1 : 0)) * (-1 / this.numVisible) * 100; let num = (this.current - this.numExtraNext() - (this.numVisible % 2 == 0 ? 1 : 0)) * (-1 / this.numVisible) * 100;

@ -200,17 +200,18 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
setIndex(index: number) { setIndex(index: number) {
this.slideIndex = index; this.slideIndex = index;
if (this.currentSlides) { if (this.currentSlides) {
this.currentSlides.current = index; this.currentSlides.setIndex(index);
} }
if (this.zoneSlides) { if (this.zoneSlides) {
this.zoneSlides.current = index; this.zoneSlides.setIndex(index);
} }
} }
setPrevious(plan: string) { setPrevious(plan: string) {
this.planService.loadPrevious(plan).subscribe(plan => { this.planService.loadPrevious(plan).subscribe(plan => {
this.setIndex(plan.current); setTimeout(() => this.setIndex(plan.current), 0);
}); });
} }
@ -267,6 +268,12 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
loadBasePlan() { loadBasePlan() {
this.planService.loadBasePlan().subscribe(plan => { this.planService.loadBasePlan().subscribe(plan => {
this.planService.currentPlan = new Plan(plan); this.planService.currentPlan = new Plan(plan);
if (this.zoneSlides) {
this.zoneSlides.setIndex(0);
}
if (this.currentSlides) {
this.currentSlides.setIndex(0);
}
}) })
} }

Loading…
Cancel
Save