From 9c6cc183f5a62e3bdbcfa75f0811d23959db24d4 Mon Sep 17 00:00:00 2001 From: rlx Date: Fri, 12 Jan 2018 15:03:56 +0100 Subject: [PATCH] timeline tiles off by one, also handle last tile width --- icf.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/icf.js b/icf.js index 0f92db6..3452666 100644 --- a/icf.js +++ b/icf.js @@ -1,5 +1,5 @@ let hashes = [] -let movie, position, frames, timelineTiles +let movie, position, frames, timelineTiles, lastTimelineWidth let timelineElement = document.getElementById('timeline') let timelineElements = [] @@ -110,6 +110,7 @@ function loadTimeline(callback) { position = Math.floor(time % mspd / mspd * movie.duration * fps) / fps frames = Math.floor(movie.duration * fps) timelineTiles = Math.ceil(frames / timelineWidth) + lastTimelineWidth = frames % timelineWidth renderTimeline() timelineLink.innerHTML = movie.title + ' (' + movie.year + ') ' + movie.director.join(', ') @@ -151,7 +152,9 @@ function renderTimeline() { while (timelines[0].left > 0) { timelines.unshift({ index: mod(timelines[0].index - 1, timelineTiles), - left: timelines[0].left - timelineWidth + left: timelines[0].left - ( + timelines[0].index == 0 ? lastTimelineWidth : timelineWidth + ) }) } while (last(timelines).left < windowWidth) { @@ -174,7 +177,7 @@ function renderTimeline() { element = document.createElement('img') element.id = 'timeline' + timeline.index element.src = 'https://media.indiancine.ma/' + movie.id - + '/timelinekeyframes64p' + (timeline.index + 1) + '.jpg' + + '/timelinekeyframes64p' + timeline.index + '.jpg' element.style.left = timeline.left + 'px' timelineElement.appendChild(element) }