timeline tiles off by one, also handle last tile width

This commit is contained in:
rlx 2018-01-12 15:03:56 +01:00
parent b25939875e
commit 9c6cc183f5
1 changed files with 6 additions and 3 deletions

9
icf.js
View File

@ -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)
}