timeline tiles off by one, also handle last tile width
This commit is contained in:
parent
b25939875e
commit
9c6cc183f5
1 changed files with 6 additions and 3 deletions
9
icf.js
9
icf.js
|
@ -1,5 +1,5 @@
|
||||||
let hashes = []
|
let hashes = []
|
||||||
let movie, position, frames, timelineTiles
|
let movie, position, frames, timelineTiles, lastTimelineWidth
|
||||||
|
|
||||||
let timelineElement = document.getElementById('timeline')
|
let timelineElement = document.getElementById('timeline')
|
||||||
let timelineElements = []
|
let timelineElements = []
|
||||||
|
@ -110,6 +110,7 @@ function loadTimeline(callback) {
|
||||||
position = Math.floor(time % mspd / mspd * movie.duration * fps) / fps
|
position = Math.floor(time % mspd / mspd * movie.duration * fps) / fps
|
||||||
frames = Math.floor(movie.duration * fps)
|
frames = Math.floor(movie.duration * fps)
|
||||||
timelineTiles = Math.ceil(frames / timelineWidth)
|
timelineTiles = Math.ceil(frames / timelineWidth)
|
||||||
|
lastTimelineWidth = frames % timelineWidth
|
||||||
renderTimeline()
|
renderTimeline()
|
||||||
timelineLink.innerHTML = movie.title + ' (' + movie.year + ') '
|
timelineLink.innerHTML = movie.title + ' (' + movie.year + ') '
|
||||||
+ movie.director.join(', ')
|
+ movie.director.join(', ')
|
||||||
|
@ -151,7 +152,9 @@ function renderTimeline() {
|
||||||
while (timelines[0].left > 0) {
|
while (timelines[0].left > 0) {
|
||||||
timelines.unshift({
|
timelines.unshift({
|
||||||
index: mod(timelines[0].index - 1, timelineTiles),
|
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) {
|
while (last(timelines).left < windowWidth) {
|
||||||
|
@ -174,7 +177,7 @@ function renderTimeline() {
|
||||||
element = document.createElement('img')
|
element = document.createElement('img')
|
||||||
element.id = 'timeline' + timeline.index
|
element.id = 'timeline' + timeline.index
|
||||||
element.src = 'https://media.indiancine.ma/' + movie.id
|
element.src = 'https://media.indiancine.ma/' + movie.id
|
||||||
+ '/timelinekeyframes64p' + (timeline.index + 1) + '.jpg'
|
+ '/timelinekeyframes64p' + timeline.index + '.jpg'
|
||||||
element.style.left = timeline.left + 'px'
|
element.style.left = timeline.left + 'px'
|
||||||
timelineElement.appendChild(element)
|
timelineElement.appendChild(element)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue