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) { function start(idx) {
var data = slideData[idx] var data = slideData[idx]
console.log(current, data) console.log('start', current, data)
if (data.zoom_to) { if (data.zooms) {
start_zoom(data) start_zoom(data)
} else if (data.video && data.video.length) { } else if (data.video && data.video.length) {
start_video(data) start_video(data)
@ -60,7 +60,7 @@ function start(idx) {
function stop(idx) { function stop(idx) {
var data = slideData[idx] var data = slideData[idx]
console.log(current, data) console.log(current, data)
if (data.zoom_to) { if (data.zooms) {
reset_zoom(data) reset_zoom(data)
} else if (data.video && data.video.length) { } else if (data.video && data.video.length) {
reset_video(data) reset_video(data)
@ -83,10 +83,10 @@ function load_slide(slide) {
if (video) { if (video) {
data.video = load_urls(video.dataset) data.video = load_urls(video.dataset)
data.container = video data.container = video
// fixme only doucments
if (data.video.length == 2) { // assumes documents if length > 1
data.zoom_from = data.video[0].split('/').pop().split('#')[0].split(',').map(a => Math.round(a)) if (data.video.length > 1) {
data.zoom_to = data.video[1].split('/').pop().split('#')[0].split(',').map(a => Math.round(a)) data.zooms = data.video.map(url => url.split('/').pop().split('#')[0].split(',').map(a => Math.round(a)))
} }
} }
return data return data
@ -121,19 +121,25 @@ window.addEventListener('blur', function(){
function reset_zoom(data) { function reset_zoom(data) {
data.zoomTimeouts.forEach(timeout => clearTimeout(timeout))
data.embed.postMessage('options', { data.embed.postMessage('options', {
'area': data.zoom_from 'area': data.zooms[0]
}) })
} }
function start_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))
setTimeout(function() {
console.log('now zoom') for (var i=1; i<data.zooms.length; i++) {
data.embed.postMessage('options', { data.zoomTimeouts = [];
'area': data.zoom_to (function(j) {
}) data.zoomTimeouts.push(setTimeout(function() {
}, Math.round(1000 * data.duration / 2)) data.embed.postMessage('options', {
'area': data.zooms[j]
})
}, Math.round(1000 * (data.duration / data.zooms.length) * j)))
})(i)
}
} }