Merge branch 'many-documents' of sanj/padmaEmbeds into master

This commit is contained in:
j 2018-03-15 10:24:54 +00:00 committed by Gitea
commit 034832f71e

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)
@ -60,7 +60,7 @@ function start(idx) {
function stop(idx) {
var data = slideData[idx]
console.log(current, data)
if (data.zoom_to) {
if (data.zooms) {
reset_zoom(data)
} else if (data.video && data.video.length) {
reset_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
@ -121,19 +121,25 @@ window.addEventListener('blur', function(){
function reset_zoom(data) {
data.zoomTimeouts.forEach(timeout => clearTimeout(timeout))
data.embed.postMessage('options', {
'area': data.zoom_from
'area': data.zooms[0]
})
}
function start_zoom(data) {
console.log('start zoon', Math.round(1000 * data.duration / 2))
setTimeout(function() {
console.log('now zoom')
// console.log('start zoon', Math.round(1000 * data.duration / 2))
for (var i=1; i<data.zooms.length; i++) {
data.zoomTimeouts = [];
(function(j) {
data.zoomTimeouts.push(setTimeout(function() {
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)
}
}