From b8ed8b806e7f4185b9ef4a05db55270992642e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20PENHO=C3=8BT?= Date: Wed, 4 Aug 2021 17:38:38 +0200 Subject: [PATCH] =?UTF-8?q?Suite=20prise=20en=20compte=20mode=20strict=20d?= =?UTF-8?q?e=20TypeScript=20+=20simplification=20it=C3=A9ration=20vers=20l?= =?UTF-8?q?a=20vid=C3=A9o=20suivante.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vCarousel.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/vCarousel.ts b/src/vCarousel.ts index b74f7ac..27f5978 100644 --- a/src/vCarousel.ts +++ b/src/vCarousel.ts @@ -49,7 +49,7 @@ export class vCarousel // Si this._firstVideoId a été fourni, on vérifie qu'il est présent dans la liste des conteneurs de vidéos. set firstVideoId(firstVideo: string|undefined) { - if((firstVideo!=="" && this._vContainers.findIndex(video => video.id === firstVideo) !== -1) || (firstVideo==="")) + if((firstVideo!==undefined && firstVideo!=="" && this._vContainers.findIndex(video => video.id === firstVideo) !== -1) || ( firstVideo==="")) this._firstVideoId=firstVideo; } @@ -109,19 +109,12 @@ export class vCarousel if(nbTurn < (vCarousel.nbVContainers-1) || vCarousel._noStop===true) { vContainer.style.display = "none"; - let nextVContainer: HTMLElement, nextVideo: HTMLMediaElement, nextHash: string; + let nextVContainer: HTMLElement, nextVideo: HTMLMediaElement, nextHash: string, nextOne=0; if(i < (vCarousel.nbVContainers-1)) - { - nextVContainer=vCarousel._vContainers[i+1].containerElt; - nextVideo=vCarousel._vContainers[i+1].videoElt; - nextHash=vCarousel._vContainers[i+1].id; - } - else - { - nextVContainer=vCarousel._vContainers[0].containerElt; - nextVideo=vCarousel._vContainers[0].videoElt; - nextHash=vCarousel._vContainers[0].id; - } + nextOne=i+1; + nextVContainer=vCarousel._vContainers[nextOne].containerElt; + nextVideo=vCarousel._vContainers[nextOne].videoElt; + nextHash=vCarousel._vContainers[nextOne].id; nextVContainer.style.display = "block"; vCarousel._currentVideo=nextVideo; // On adapte l'ancre de l'url de manière à ce qu'elle soit cohérente avec la vidéo affichée.