This commit is contained in:
parent
0b7d26f150
commit
b921801e6a
1 changed files with 13 additions and 6 deletions
|
@ -5,10 +5,6 @@
|
|||
let listingIndex = 0;
|
||||
|
||||
function updateListingIndex(amount: number): void {
|
||||
if (listingIndex == amount - 2) {
|
||||
fetchData = api.fetchData();
|
||||
}
|
||||
|
||||
if (listingIndex >= amount - 1) {
|
||||
listingIndex = 0;
|
||||
} else {
|
||||
|
@ -16,16 +12,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
function handleTime(time: number, listingsAmount: number): void {
|
||||
function handleTime(
|
||||
time: number,
|
||||
index: number,
|
||||
listingsAmount: number
|
||||
): void {
|
||||
if (index == listingsAmount - 2) {
|
||||
fetchData = api.fetchData();
|
||||
}
|
||||
|
||||
setTimeout(() => updateListingIndex(listingsAmount), time * 1000);
|
||||
}
|
||||
|
||||
function handleVideoLoad(
|
||||
time: number | undefined,
|
||||
index: number,
|
||||
listingsAmount: number
|
||||
): void {
|
||||
if (time) {
|
||||
handleTime(time, listingsAmount);
|
||||
handleTime(time, index, listingsAmount);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -44,6 +49,7 @@
|
|||
on:load={() =>
|
||||
handleTime(
|
||||
data.listings[listingIndex].time || 10,
|
||||
listingIndex,
|
||||
data.listings.length
|
||||
)}
|
||||
/>
|
||||
|
@ -55,6 +61,7 @@
|
|||
on:load={() =>
|
||||
handleVideoLoad(
|
||||
data.listings[listingIndex].time,
|
||||
listingIndex,
|
||||
data.listings.length
|
||||
)}
|
||||
on:ended={() => updateListingIndex(data.listings.length)}
|
||||
|
|
Loading…
Reference in a new issue