work for an arbitrary number of document zooms

This commit is contained in:
Sanjay Bhangar 2018-03-14 22:56:26 +05:30
parent 9cb4300004
commit 9ee095b6db

View File

@ -49,8 +49,8 @@ function previous() {
function start(idx) {
var data = slideData[idx]
console.log(current, data)
if (data.zoom_to) {
console.log('start', current, data)
if (data.zooms) {
start_zoom(data)
} else if (data.video && data.video.length) {
start_video(data)
@ -83,10 +83,10 @@ function load_slide(slide) {
if (video) {
data.video = load_urls(video.dataset)
data.container = video
// fixme only doucments
if (data.video.length == 2) {
data.zoom_from = data.video[0].split('/').pop().split('#')[0].split(',').map(a => Math.round(a))
data.zoom_to = data.video[1].split('/').pop().split('#')[0].split(',').map(a => Math.round(a))
// assumes documents if length > 1
if (data.video.length > 1) {
data.zooms = data.video.map(url => url.split('/').pop().split('#')[0].split(',').map(a => Math.round(a)))
}
}
return data
@ -127,13 +127,17 @@ function reset_zoom(data) {
}
function start_zoom(data) {
console.log('start zoon', Math.round(1000 * data.duration / 2))
// console.log('start zoon', Math.round(1000 * data.duration / 2))
for (var i=1; i<data.zooms.length; i++) {
(function(j) {
setTimeout(function() {
console.log('now zoom')
data.embed.postMessage('options', {
'area': data.zoom_to
'area': data.zooms[j]
})
}, Math.round(1000 * data.duration / 2))
}, Math.round(1000 * (data.duration / data.zooms.length) * j))
})(i)
}
}