var Flickity = require("flickity"); import { vCarousel } from "./vCarousel"; var selectFlickityForHash = function (flickityCarousel, urlHash) { var nb = 0, find = false; for (var _i = 0, _a = flickityCarousel.cells; _i < _a.length; _i++) { var cel = _a[_i]; var childrens = cel.element.childNodes; for (var i = 0, c = childrens.length; i < c; i++) { if (childrens[i].nodeType === Node.ELEMENT_NODE) { if (childrens[i].hash != undefined && childrens[i].hash === urlHash) { flickityCarousel.select(nb); find = true; break; } } } nb++; } if (find === false) console.error("L'ancre fournie par l'url n'a pas été trouvée dans le carrousel Flickity."); }; try { var imgCarousel = document.querySelector(".img-carousel"); var flktyCarousel_1 = new Flickity(imgCarousel, { accessibility: true, cellAlign: "center", contain: true, rightToLeft: true, wrapAround: true, }); var videosContainers = ["vFunanbule", "vForgeron", "vCircuit"]; var testvCarousel_1 = new vCarousel(); testvCarousel_1.vContainers = videosContainers; if (window.location.hash !== undefined && window.location.hash !== "") { testvCarousel_1.firstVideoId = window.location.hash.replace("#", ""); selectFlickityForHash(flktyCarousel_1, location.hash); } else testvCarousel_1.firstVideoId = ""; testvCarousel_1.run(); var selectLinks = document.querySelectorAll(".selectVideo"); var _loop_1 = function (i) { var link = selectLinks[i]; link.addEventListener("click", function (e) { testvCarousel_1.firstVideoId = link.hash.replace("#", ""); testvCarousel_1.playFirstVideo = true; testvCarousel_1.playNextVideos = true; testvCarousel_1.run(); }); }; for (var i = 0; i < selectLinks.length; i++) { _loop_1(i); } window.addEventListener('hashchange', function () { selectFlickityForHash(flktyCarousel_1, location.hash); }); } catch (e) { console.error(e); }