timeline.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. function customTimeline() {
  2. // titres de parties dans le tableau
  3. let mainpartTitless = document.querySelectorAll('.isMainPart');
  4. for (let mainpartTitles of mainpartTitless) {
  5. if (mainpartTitles.nextElementSibling.classList.contains('isSubPart')) {
  6. mainpartTitles.firstElementChild.firstElementChild.style.height = "1.5rem";
  7. mainpartTitles.firstElementChild.style.marginBottom = "-0.25rem";
  8. mainpartTitles.style.borderBottom = "0";
  9. mainpartTitles.style.paddingBottom = "0";
  10. mainpartTitles.nextElementSibling.style.paddingTop = "0";
  11. }
  12. }
  13. // couleurs titres
  14. let colors = [
  15. {'red' : 'cf0118'},
  16. {'blue1': '0101c4'},
  17. {'blue2': '01049e'},
  18. {'blue3': '010678'},
  19. {'blue4': '010952'},
  20. {'blue5': '00113c'},
  21. {'yellow1': 'ade719'},
  22. {'yellow2': '8cc700'},
  23. {'yellow3': '74af00'},
  24. {'yellow4': '5c9900'},
  25. {'yellow5': '377600'},
  26. {'pink1': 'cf0118'},
  27. {'pink2': 'a10418'}
  28. ];
  29. let titles = document.querySelectorAll('.isMainPart, .isSubPart');
  30. let partTitles = [];
  31. for (let title of titles) {
  32. if (!title.nextElementSibling.classList.contains('isSubPart')) {
  33. partTitles.push(title);
  34. }
  35. }
  36. for (let i = 0; i < partTitles.length; i++) {
  37. if (partTitles[i].previousElementSibling?.classList.contains('isMainPart')) {
  38. partTitles[i].previousElementSibling.firstElementChild.firstElementChild.style.backgroundColor = "#" + Object.values(colors[i])[0];
  39. }
  40. partTitles[i].firstElementChild.firstElementChild.style.backgroundColor = "#" + Object.values(colors[i])[0];
  41. }
  42. // set parts rectangles
  43. function convertToSeconds(timeStr) {
  44. let [hourStr, minStr] = timeStr.split('h');
  45. if (!minStr) {
  46. minStr = hourStr;
  47. hourStr = '0';
  48. }
  49. minStr = minStr.replace('’', ':');
  50. minStr = minStr.replace("'", ':');
  51. const [min, sec] = minStr.split(':');
  52. return parseInt(hourStr) * 3600 + parseInt(min) * 60 + parseInt(sec);
  53. }
  54. let partTimesNodes = document.querySelectorAll('body #app main tbody tr:not(.isContentPart) + tr:not(.isSubPart) td:first-of-type');
  55. let partTimes = Array.from(partTimesNodes);
  56. for (let i = 0; i < partTimes.length; i++) {
  57. partTimes[i] = convertToSeconds(partTimes[i].innerText);
  58. }
  59. let lastTime = document.querySelectorAll('body #app main tbody tr:last-of-type td:first-of-type');
  60. partTimes.push(convertToSeconds(lastTime[0].innerText));
  61. let partDurations = [];
  62. for (let i = 0; i < partTimes.length - 1; i++) {
  63. partDurations.push(partTimes[i + 1] - partTimes[i]);
  64. }
  65. let totalTime = convertToSeconds(lastTime[0].innerText);
  66. let tlContainer, tlContainerHeight;
  67. let partBlockHeights = [];
  68. let activePartIndex = 0;
  69. function getAllHeights() {
  70. partBlockHeights = [];
  71. tlContainer = document.querySelector('#timeline_container');
  72. let header = document.querySelector('header'), footer = document.querySelector('footer');
  73. tlContainer.style.height = `calc(100vh - ${header.offsetHeight}px - ${footer.offsetHeight}px - 60px)`;
  74. tlContainer.style.top = `${document.querySelector('header').offsetHeight + 30}px`;
  75. tlContainerHeight = tlContainer.offsetHeight;
  76. for (let partDuration of partDurations) {
  77. partBlockHeights.push(partDuration / totalTime * tlContainerHeight);
  78. }
  79. }
  80. getAllHeights();
  81. function drawFriseRects() {
  82. for (let i = 0; i < partBlockHeights.length; i++) {
  83. let partDiv = document.createElement('div');
  84. partDiv.style.width = "22px";
  85. partDiv.style.height = partBlockHeights[i] + "px";
  86. partDiv.style.backgroundColor = "#" + Object.values(colors[i])[0];
  87. partDiv.style.borderBottom = "solid 1px #010d19";
  88. partDiv.style.borderTop = "solid 1px #010d19";
  89. partDiv.style.transition = "width 0.3s ease-out";
  90. partDiv.style.cursor = "pointer";
  91. tlContainer.prepend(partDiv);
  92. tlContainer.children[0].addEventListener("mouseenter", function() {
  93. let el = tlContainer.children[tlContainer.children.length - 1 - i];
  94. if (Array.from(el.parentNode.children).length - Array.from(el.parentNode.children).indexOf(el) - 1 != activePartIndex) {
  95. el.style.width = "32px";
  96. toggleTitleHover(i, 'show');
  97. }
  98. });
  99. tlContainer.children[0].addEventListener("mouseleave", function() {
  100. let el = tlContainer.children[tlContainer.children.length - 1 - i];
  101. if (Array.from(el.parentNode.children).length - Array.from(el.parentNode.children).indexOf(el) - 1 != activePartIndex) {
  102. el.style.width = "22px";
  103. }
  104. toggleTitleHover(i, 'hide');
  105. });
  106. tlContainer.children[0].addEventListener("click", function() {
  107. isScrollingFromGrab = false;
  108. titresFrise[i].el.scrollIntoView({ behavior: 'smooth', block: 'center' });
  109. });
  110. }
  111. }
  112. drawFriseRects();
  113. window.addEventListener('resize', () => {
  114. while(tlContainer.lastChild) {
  115. tlContainer.removeChild(tlContainer.lastChild);
  116. }
  117. getAllHeights();
  118. drawFriseRects();
  119. setPartRects();
  120. });
  121. // detect if is scrolling
  122. let previousScroll;
  123. function isWindowScrolling() {
  124. let currentScroll = window.scrollY;
  125. if (currentScroll !== previousScroll) {
  126. previousScroll = currentScroll;
  127. return true;
  128. } else {
  129. return false;
  130. }
  131. }
  132. // titres parties frise
  133. let titreFriseEl = document.createElement('div');
  134. let elements = Array.from(document.querySelectorAll('.isMainPart, .isSubPart'));
  135. let mainWithoutSubAfter = [];
  136. let mainWithSubAfter = [];
  137. let subWithoutMainBefore = [];
  138. let lastMain = null;
  139. let grabbing = false;
  140. for (let i = 0; i < elements.length; i++) {
  141. let current = elements[i];
  142. let next = elements[i + 1];
  143. if (current.classList.contains('isMainPart')) {
  144. lastMain = current;
  145. if (next && next.classList.contains('isSubPart')) {
  146. mainWithSubAfter.push({ index: i, main: current.innerText, sub: next.innerText, el: elements[i] });
  147. } else {
  148. mainWithoutSubAfter.push({ index: i, main: current.innerText, sub: "", el: elements[i] });
  149. }
  150. }
  151. if (current.classList.contains('isSubPart')) {
  152. let prevMain = lastMain && lastMain.classList.contains('isMainPart') ? lastMain.innerText : "";
  153. subWithoutMainBefore.push({ index: i, main: prevMain, sub: current.innerText, el: elements[i] });
  154. }
  155. }
  156. let titresFrise = [...mainWithoutSubAfter, ...mainWithSubAfter, ...subWithoutMainBefore];
  157. titresFrise.sort((a, b) => a.index - b.index);
  158. for (let i = titresFrise.length - 1; i > 0; i--) {
  159. let current = titresFrise[i];
  160. let next = titresFrise[i - 1];
  161. if (current.main === next.main && current.sub === next.sub) {
  162. titresFrise.splice(i, 1);
  163. }
  164. }
  165. titreFriseEl.setAttribute('id', 'titres_frise');
  166. titreFriseEl.innerHTML = `
  167. <p class="uppercase">${getCurrentTime(titresFrise[0].el)}</p>
  168. <p>${titresFrise[0].main}</p>
  169. <p class="font-authentic-60">${titresFrise[0].sub}</p>
  170. `;
  171. titreFriseEl.style.fontSize = '0.9em';
  172. titreFriseEl.style.backgroundColor = 'rgba(1, 13, 25, 0.6)';
  173. titreFriseEl.style.zIndex = '20';
  174. titreFriseEl.style.position = 'fixed';
  175. titreFriseEl.style.left = '60px';
  176. titreFriseEl.style.width = '10vw';
  177. titreFriseEl.style.lineHeight = '1.2';
  178. titreFriseEl.style.marginTop = '-8px';
  179. titreFriseEl.style.top = `${document.querySelector('#timeline_container').getBoundingClientRect().top}px`;
  180. let main = document.querySelector('#main');
  181. main.prepend(titreFriseEl);
  182. // création et togle des titres au survol des div de la timeline
  183. function drawFixedTitles() {
  184. let tlContainer = document.querySelector('#timeline_container');
  185. let fixedTitlesContainer = document.createElement('div');
  186. fixedTitlesContainer.setAttribute('id', 'fixedTitlesContainer');
  187. main.prepend(fixedTitlesContainer);
  188. for (let index = 0; index < titresFrise.length; index++) {
  189. let titreFixedEl = document.createElement('div');
  190. titreFixedEl.style.position = 'fixed';
  191. titreFixedEl.style.zIndex = 1;
  192. titreFixedEl.style.display = 'none';
  193. titreFixedEl.style.opacity = '0';
  194. titreFixedEl.style.transition = 'opacity 0.3s ease-out';
  195. titreFixedEl.style.width = '10vw';
  196. titreFixedEl.style.top = `${tlContainer.children[index].getBoundingClientRect().top - 8}px`;
  197. titreFixedEl.style.left = '60px';
  198. titreFixedEl.style.fontSize = '0.9em';
  199. titreFixedEl.style.lineHeight = '1.2';
  200. let titreFixedElContent = document.createElement('p');
  201. titreFixedElContent.innerHTML = `
  202. <p>${titresFrise[titresFrise.length - index - 1].main}</p>
  203. <p class="font-authentic-60">${titresFrise[titresFrise.length - index - 1].sub}</p>
  204. `;
  205. titreFixedElContent.style.backgroundColor = '#010d19';
  206. titreFixedEl.append(titreFixedElContent);
  207. let topGradient = document.createElement('div');
  208. topGradient.style.height = '10px';
  209. topGradient.style.width = '100%';
  210. topGradient.style.background = 'linear-gradient(to bottom, transparent, #010d19)';
  211. titreFixedEl.prepend(topGradient);
  212. let bottomGradient = document.createElement('div');
  213. bottomGradient.style.height = '10px';
  214. bottomGradient.style.width = '100%';
  215. bottomGradient.style.background = 'linear-gradient(to top, transparent, #010d19)';
  216. titreFixedEl.append(bottomGradient);
  217. fixedTitlesContainer.prepend(titreFixedEl);
  218. }
  219. }
  220. drawFixedTitles();
  221. function toggleTitleHover(elIndex, state) {
  222. let fixedTitlesContainer = document.querySelector('#fixedTitlesContainer');
  223. let el = fixedTitlesContainer.children[elIndex];
  224. if (state === 'show') {
  225. el.style.display = 'block';
  226. setTimeout(() => {
  227. el.style.opacity = '1';
  228. }, 1);
  229. } else if (state === 'hide') {
  230. el.style.opacity = '0';
  231. setTimeout(() => {
  232. el.style.display = 'none';
  233. }, 300);
  234. }
  235. }
  236. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  237. // ICI IL Y A LE GRAB DU CURSEUR DE LA TL
  238. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  239. // make the cursor move on scroll
  240. let cursor = document.querySelector('#cursor');
  241. cursor.style.top = `${document.querySelector('#timeline_container').getBoundingClientRect().top}px`;
  242. cursor.style.cursor = 'grab';
  243. let titres = document.querySelector('#titres_frise');
  244. titres.style.cursor = 'grab';
  245. let partRects;
  246. function setPartRects() {
  247. partRects = document.querySelectorAll('#timeline_container div');
  248. partRects = Array.from(partRects);
  249. partRects = partRects.reverse();
  250. partRects[0].style.width = '32px';
  251. }
  252. setPartRects();
  253. document.addEventListener("scroll", () => {
  254. if (!grabbing) {
  255. displayCurrentPartTitle(getCurrentPartFromScroll());
  256. if (document.documentElement.scrollTop === 0) {
  257. let firstTimeText = document.querySelector('tbody tr:nth-of-type(2) td:first-of-type');
  258. titres.firstElementChild.innerText = firstTimeText.innerText;
  259. } else if (document.documentElement.scrollTop + window.innerHeight >= document.body.scrollHeight) {
  260. let lastTimeText = document.querySelector('tbody tr:last-of-type td:first-of-type');
  261. titres.firstElementChild.innerText = lastTimeText.innerText;
  262. }
  263. moveCursorFromScroll(getCurrentPartFromScroll());
  264. }
  265. });
  266. function makeElementDraggable(element, relatedEl) {
  267. let offsetY;
  268. element.addEventListener('mousedown', (e) => {
  269. let elTransformY;
  270. if (!element.style.transform) {
  271. elTransformY = 0;
  272. } else {
  273. elTransformY = +element.style.transform.split('(')[1].split('p')[0];
  274. }
  275. e.preventDefault();
  276. grabbing = true;
  277. offsetY = e.clientY - elTransformY;
  278. element.style.cursor = 'grabbing';
  279. });
  280. document.addEventListener('mousemove', (e) => {
  281. if (grabbing) {
  282. if (e.clientY < tlContainerHeight + tlContainer.offsetTop && e.clientY > tlContainer.offsetTop) {
  283. const y = e.clientY - offsetY;
  284. element.style.transform = `translateY(${y}px)`;
  285. relatedEl.style.transform = `translateY(${y}px)`;
  286. if (!isNaN(y)) displayCurrentPartTitle(getCurrentPartFromCursor(y));
  287. } else if (e.clientY < tlContainer.offsetTop + 10) {
  288. element.style.transform = `translateY(0px)`;
  289. relatedEl.style.transform = `translateY(0px)`;
  290. let firstTimeText = document.querySelector('tbody tr:nth-of-type(2) td:first-of-type');
  291. titres.firstElementChild.innerText = firstTimeText.innerText;
  292. } else if (e.clientY >= tlContainerHeight + tlContainer.offsetTop) {
  293. element.style.transform = `translateY(${tlContainerHeight}px)`;
  294. relatedEl.style.transform = `translateY(${tlContainerHeight}px)`;
  295. let lastTimeText = document.querySelector('tbody tr:last-of-type td:first-of-type');
  296. titres.firstElementChild.innerText = lastTimeText.innerText;
  297. }
  298. }
  299. });
  300. document.addEventListener('mouseup', () => {
  301. if (grabbing) scrollOnGrab(element);
  302. element.style.cursor = 'grab';
  303. grabbing = false;
  304. });
  305. }
  306. makeElementDraggable(cursor, titres);
  307. makeElementDraggable(titres, cursor);
  308. // get heights of parts dans le tableau et dans la timeline
  309. function getSteps() {
  310. let tlElSteps = [];
  311. for (let i = 0; i < partRects.length; i++) {
  312. tlElSteps.push(partRects[i].offsetTop);
  313. }
  314. let titles = document.querySelectorAll('.isMainPart, .isSubPart');
  315. let scrollSteps = [];
  316. for (let title of titles) {
  317. let nextLine = title.nextElementSibling;
  318. if (!nextLine?.classList.contains('isSubPart')) {
  319. scrollSteps.push(title.offsetTop);
  320. }
  321. }
  322. return({
  323. 'tlElSteps':tlElSteps,
  324. 'scrollSteps':scrollSteps
  325. });
  326. }
  327. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  328. // ICI IL Y A LE SCROLL DU GRAB
  329. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  330. let isScrollingFromGrab = false;
  331. function scrollOnGrab(el) {
  332. let scrollValue =
  333. ((getSteps().scrollSteps[getCursorPositionInTimelinePart(el).stepAfterMouseUp] - getSteps().scrollSteps[getCursorPositionInTimelinePart(el).stepAfterMouseUp - 1]) * getCursorPositionInTimelinePart(el).proportionInPart)
  334. + getSteps().scrollSteps[getCursorPositionInTimelinePart(el).stepAfterMouseUp];
  335. isScrollingFromGrab = true;
  336. window.scrollTo({ top: scrollValue, behavior: 'smooth' });
  337. setTimeout(() => {
  338. isScrollingFromGrab = false;
  339. }, 2000);
  340. }
  341. function getCursorPositionInTimelinePart(el) {
  342. let elTransformY;
  343. if (!el.style.transform) {
  344. elTransformY = 0;
  345. } else {
  346. elTransformY = +el.style.transform.split('(')[1].split('p')[0];
  347. }
  348. let tlPartHeight, tlPartBottom, tlPartTop, proportionInPart, stepAfterMouseUp;
  349. for (let j = 0; j < partRects.length; j++) {
  350. if (j === getCurrentPartFromCursor(elTransformY)) {
  351. tlPartHeight = partRects[j].getBoundingClientRect().height;
  352. tlPartBottom = partRects[j].getBoundingClientRect().top - tlContainer.getBoundingClientRect().top;
  353. tlPartTop = tlPartBottom - tlPartHeight;
  354. proportionInPart = ((tlPartHeight - (elTransformY - tlPartTop)) / tlPartHeight) * -1;
  355. if (proportionInPart > 0 && proportionInPart < 1) {
  356. stepAfterMouseUp = j;
  357. return {stepAfterMouseUp, proportionInPart};
  358. } else {
  359. stepAfterMouseUp = j;
  360. proportionInPart = 0;
  361. return {stepAfterMouseUp, proportionInPart};
  362. }
  363. }
  364. }
  365. }
  366. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  367. // ICI IL Y A LE RAPPORT SCROLL / TIMELINE
  368. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  369. function moveCursorFromScroll(currentPartIndex) {
  370. if (!isScrollingFromGrab) {
  371. let currentScroll = window.scrollY;
  372. let cursorTopValue = 0;
  373. let tlPartHeight, tlPartBottom;
  374. for (let j = 0; j < partRects.length; j++) {
  375. tlPartHeight = partRects[j].getBoundingClientRect().height
  376. tlPartBottom = partRects[j].getBoundingClientRect().top - tlContainer.getBoundingClientRect().top;
  377. cursorTopValue = tlPartBottom;
  378. // get the amount of the current scrollpart scrolled
  379. if (j === currentPartIndex) break;
  380. }
  381. let currentScrollPartBottom = getSteps().scrollSteps[currentPartIndex - 1] ? getSteps().scrollSteps[currentPartIndex - 1] : 0;
  382. let currentScrollPartHeight;
  383. if (getSteps().scrollSteps[currentPartIndex + 1]) {
  384. currentScrollPartHeight = getSteps().scrollSteps[currentPartIndex + 1] - currentScrollPartBottom;
  385. } else {
  386. currentScrollPartHeight = document.querySelector('body').scrollHeight - currentScrollPartBottom;
  387. }
  388. let currentScrollSincePartBottom = currentScroll - currentScrollPartBottom;
  389. let scrollPartProportion = currentScrollSincePartBottom / currentScrollPartHeight;
  390. cursorTopValue = cursorTopValue + tlPartHeight * (tlPartHeight / tlPartHeight * (scrollPartProportion - 0.3));
  391. if (cursorTopValue > 0) {
  392. cursor.style.transform = `translateY(${cursorTopValue}px)`;
  393. titres.style.transform = `translateY(${cursorTopValue}px)`;
  394. } else {
  395. cursor.style.transform = `translateY(0px)`;
  396. titres.style.transform = `translateY(0px)`;
  397. }
  398. }
  399. }
  400. let prevPartIndex = 0;
  401. let lastCallTimestamp = 0;
  402. function displayCurrentPartTitle(currentPartIndex) {
  403. if (isNaN(currentPartIndex)) currentPartIndex = 0;
  404. const currentTime = performance.now();
  405. if (currentTime - lastCallTimestamp >= 400) {
  406. lastCallTimestamp = currentTime;
  407. titres.firstElementChild.innerText = getCurrentTime(titresFrise[currentPartIndex]?.el); // ICI POUR METTRE LE TEMPS BIEN
  408. setTimeout(() => {
  409. if (isWindowScrolling()) {
  410. setTimeout(() => {
  411. titres.firstElementChild.innerText = getCurrentTime(titresFrise[currentPartIndex]?.el);
  412. }, 400);
  413. }
  414. }, 200);
  415. }
  416. let mainEl = titres.children[1];
  417. let subEl = titres.lastElementChild;
  418. if (mainEl.innerText != titresFrise[currentPartIndex]?.main || subEl.innerText != titresFrise[currentPartIndex]?.sub) {
  419. mainEl.innerText = titresFrise[currentPartIndex]?.main;
  420. subEl.innerText = titresFrise[currentPartIndex]?.sub;
  421. partRects[prevPartIndex].style.width = '22px';
  422. partRects[currentPartIndex].style.width = '32px';
  423. }
  424. activePartIndex = currentPartIndex;
  425. prevPartIndex = currentPartIndex;
  426. }
  427. function getCurrentPartFromScroll() {
  428. let currentScroll = window.scrollY;
  429. for (let i = 0; i < getSteps().scrollSteps.length; i++) {
  430. if (
  431. (currentScroll + window.innerHeight / 2 >= getSteps().scrollSteps[i]
  432. && currentScroll + window.innerHeight / 2 <= getSteps().scrollSteps[i + 1]) ||
  433. (currentScroll + window.innerHeight / 2 >= getSteps().scrollSteps[i]
  434. && i === getSteps().scrollSteps.length - 1)
  435. ) {
  436. return(i);
  437. }
  438. }
  439. }
  440. function getCurrentPartFromCursor(cursorTransformY) {
  441. for (let i = 0; i < getSteps().tlElSteps.length; i++) {
  442. if (cursorTransformY >= getSteps().tlElSteps[i] && cursorTransformY < getSteps().tlElSteps[i + 1]) {
  443. return(i);
  444. } else if (cursorTransformY > getSteps().tlElSteps[getSteps().tlElSteps.length - 1]) {
  445. return(getSteps().tlElSteps.length - 1);
  446. }
  447. }
  448. }
  449. ///////////////////////////////////////
  450. // ICI LE GETCURRENTTIME !!!!!!!!!!!!!!
  451. ///////////////////////////////////////
  452. function getCurrentTime(titleEl) {
  453. let nextRow = titleEl?.nextElementSibling;
  454. if (!grabbing) {
  455. while(nextRow) {
  456. if (nextRow.offsetTop - window.innerHeight / 4 > window.scrollY &&
  457. nextRow.classList.contains('isContentPart')) {
  458. return(nextRow.firstElementChild.innerText);
  459. }
  460. nextRow = nextRow.nextElementSibling;
  461. }
  462. } else {
  463. let cursor = document.querySelector('#cursor');
  464. let allRowsUnder = [];
  465. nextRow = nextRow.nextElementSibling.nextElementSibling;
  466. while(nextRow) {
  467. if (nextRow.classList.contains('isMainPart') || nextRow.classList.contains('isSubPart')) {
  468. break;
  469. }
  470. allRowsUnder.push(nextRow);
  471. nextRow = nextRow.nextElementSibling;
  472. }
  473. let currentRowIndex = Math.floor(allRowsUnder.length * getCursorPositionInTimelinePart(cursor).proportionInPart);
  474. if (currentRowIndex - 20 >= 0) {
  475. return allRowsUnder[currentRowIndex - 20].firstElementChild.innerText;
  476. } else {
  477. return allRowsUnder[0].firstElementChild.innerText;
  478. }
  479. }
  480. }
  481. }
  482. export { customTimeline };