Fixed some plan loading init issues

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

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

@ -135,13 +135,20 @@ export class CarouselComponent<T> implements OnInit, AfterViewInit {
setIndex(slideIndex: number) {
this.current = slideIndex;
for (let i = Math.max(-this.numExtraPrev(), 0); i <= Math.min(this.numExtraNext(), this.slides!.length - 1); i++) {
this.visibleSlides?.push({
index: this.current + i,
hasBeenVisible: false,
currentlyIntersecting: false,
});
console.log("setIndex", slideIndex);
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({
index: this.current + i,
hasBeenVisible: false,
currentlyIntersecting: false,
});
}
}
this.onChange();
@ -192,15 +199,18 @@ export class CarouselComponent<T> implements OnInit, AfterViewInit {
const safetyFactor = this.numVisible == 1 ? 1 : 2;
{
const intersecting = this.visibleSlides?.filter(e => e.currentlyIntersecting).sort((e1, e2) => e1.index - e2.index);
const lowestIntersecting = intersecting![0];
this.visibleSlides = this.visibleSlides?.filter(e => e.index + safetyFactor >= lowestIntersecting!.index && e.index >= this.current - this.numExtraPrev());
if (intersecting && intersecting.length > 0) {
const lowestIntersecting = intersecting![0];
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 highestIntersecting = intersecting![0]
this.visibleSlides = this.visibleSlides?.filter(e => e.index - safetyFactor <= highestIntersecting!.index && e.index <= this.current + this.numExtraNext());
if (intersecting && intersecting.length > 0) {
const highestIntersecting = intersecting![0]
this.visibleSlides = this.visibleSlides?.filter(e => e.index - safetyFactor <= highestIntersecting!.index && e.index <= this.current + this.numExtraNext());
}
}
}

@ -200,17 +200,18 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
setIndex(index: number) {
this.slideIndex = index;
if (this.currentSlides) {
this.currentSlides.current = index;
this.currentSlides.setIndex(index);
}
if (this.zoneSlides) {
this.zoneSlides.current = index;
this.zoneSlides.setIndex(index);
}
}
setPrevious(plan: string) {
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() {
this.planService.loadBasePlan().subscribe(plan => {
this.planService.currentPlan = new Plan(plan);
if (this.zoneSlides) {
this.zoneSlides.setIndex(0);
}
if (this.currentSlides) {
this.currentSlides.setIndex(0);
}
})
}

Loading…
Cancel
Save