|
|
|
@ -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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|