/*VERSION 18.11.2017 16:25*/
;(function () {
"use strict";
/*
TODO:
1. When list length is odd we need to adjust list in order to display active item as centered
2. Obscure not active (not centered) list items and reveal active/centered list item
*/
/*============================*\
CONSTANTS/VARIABLES
/*============================*/
const songsList = document.getElementById("songs-list");
const songsListItems = songsList.querySelectorAll(".o-songs-list__item"); // as fallback Array.From should be used before iterating over this list
const songListItemWidth = songsListItems[0].offsetWidth + 16; /*width + margin on each side of the list item (e.g. if margin is margin 0 8px; then we should add 16 -> 8 * 2 [margin-right & margin-left] )*/
const btnsController = document.querySelector(".c-player__buttons");
const LIST_ITEM_CLASS = "jsListItem";
const LIST_ITEM_ACTIVE_CLASS = "is-active";
const LIST_ITEM_ANIMATED_CLASS = "is-animated";
const FAKE_LI_CLASS_NAME = "c-fake-list-item";
let songsListMoveCounter = parseInt(songsListItems.length / 2);//getCenterIndex(songsListItems);
// should be called after songsListMoveCounter has been defined
// in this case our fake element, if needed, will not be calculated
// in the overall amount of the available list items
adjustListDimensions(songsList, songsListItems);
// Setup
btnsController.addEventListener("click", onBtnsControllerClick);
songsList.addEventListener("click", onListItemClick);
/*============================*\
EVENTS
/*============================*/
function onBtnsControllerClick (e) {
const currentClickedElem = e.target;
const currentClickedElemID = currentClickedElem.id;
let currentListItem;
if(currentClickedElemID === "btn-next" || currentClickedElemID === "btn-prev") {
if(currentClickedElemID === "btn-next") {
songsListMoveCounter += 1;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.