diff --git a/src/example.js b/src/example.js deleted file mode 100644 index 6fd0a5b..0000000 --- a/src/example.js +++ /dev/null @@ -1,24 +0,0 @@ -import { vCarousel } from "./vCarousel"; -try { - 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("#", ""); - 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.run(); - }); - }; - for (var i = 0; i < selectLinks.length; i++) { - _loop_1(i); - } -} -catch (e) { - console.error(e); -} diff --git a/src/exampleFlickity.js b/src/exampleFlickity.js deleted file mode 100644 index 930c298..0000000 --- a/src/exampleFlickity.js +++ /dev/null @@ -1,60 +0,0 @@ -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); -} diff --git a/src/vCarousel.js b/src/vCarousel.js deleted file mode 100644 index 1a51cfc..0000000 --- a/src/vCarousel.js +++ /dev/null @@ -1,119 +0,0 @@ -var errors = require("./errors.js"); -var vCarousel = (function () { - function vCarousel() { - this._vContainers = []; - this._playFirstVideo = false; - this._playNextVideos = false; - this._noStop = false; - this.nbVContainers = 0; - } - Object.defineProperty(vCarousel.prototype, "vContainers", { - set: function (vContainersIds) { - for (var _i = 0, vContainersIds_1 = vContainersIds; _i < vContainersIds_1.length; _i++) { - var containerId = vContainersIds_1[_i]; - var checkContainerExist = document.getElementById(containerId); - if (checkContainerExist === null) - throw new Error(errors.elementNotFound + containerId); - else { - var checkVideoExist = document.querySelector("#" + containerId + " video"); - if (checkVideoExist === null) - throw new Error(errors.videoNotFound + containerId); - else - this._vContainers.push({ id: containerId, containerElt: checkContainerExist, videoElt: checkVideoExist }); - } - } - this.nbVContainers = this._vContainers.length; - if (this.nbVContainers < 2) - throw new Error(errors.need2Videos); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(vCarousel.prototype, "firstVideoId", { - get: function () { - return this._firstVideoId; - }, - set: function (firstVideo) { - if ((firstVideo !== "" && this._vContainers.findIndex(function (video) { return video.id === firstVideo; }) !== -1) || (firstVideo === "")) - this._firstVideoId = firstVideo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(vCarousel.prototype, "playFirstVideo", { - set: function (playFirstVideo) { - this._playFirstVideo = playFirstVideo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(vCarousel.prototype, "playNextVideos", { - set: function (playNextVideos) { - this._playNextVideos = playNextVideos; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(vCarousel.prototype, "noStop", { - set: function (noStop) { - this._noStop = noStop; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(vCarousel.prototype, "currentVideo", { - get: function () { - return this._currentVideo; - }, - enumerable: true, - configurable: true - }); - vCarousel.prototype.run = function () { - var vCarousel = this; - if (vCarousel.nbVContainers < 2) - throw new Error(errors.needVideosProvided); - var _loop_1 = function (i) { - var vContainer = vCarousel._vContainers[i].containerElt; - var video = vCarousel._vContainers[i].videoElt; - if ((vCarousel._firstVideoId !== undefined && vCarousel._vContainers[i].id !== vCarousel._firstVideoId) || (vCarousel._firstVideoId === undefined && i !== 0) || vCarousel._firstVideoId === "") - vContainer.style.display = "none"; - else { - if (vCarousel._currentVideo !== undefined && !vCarousel._currentVideo.paused) - vCarousel._currentVideo.pause(); - vContainer.style.display = "block"; - vCarousel._currentVideo = video; - if (vCarousel._playFirstVideo === true) - video.play(); - } - nbTurn = 0; - video.addEventListener("ended", function () { - if (nbTurn < (vCarousel.nbVContainers - 1) || vCarousel._noStop === true) { - vContainer.style.display = "none"; - var nextVContainer = void 0, nextVideo = void 0, nextHash = void 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; - } - nextVContainer.style.display = "block"; - vCarousel._currentVideo = nextVideo; - window.location.assign("#" + nextHash); - if (vCarousel._playNextVideos === true) - nextVideo.play(); - nbTurn++; - } - }); - }; - var nbTurn; - for (var i = 0; i < vCarousel.nbVContainers; i++) { - _loop_1(i); - } - }; - return vCarousel; -}()); -export { vCarousel };