From 9ee095b6db7f5ae130280ca82e82b548a4e0b4eb Mon Sep 17 00:00:00 2001 From: Sanjay Bhangar Date: Wed, 14 Mar 2018 22:56:26 +0530 Subject: [PATCH] work for an arbitrary number of document zooms --- example/example.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/example/example.js b/example/example.js index f897752..6be8a32 100644 --- a/example/example.js +++ b/example/example.js @@ -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)) - setTimeout(function() { - console.log('now zoom') - data.embed.postMessage('options', { - 'area': data.zoom_to - }) - }, Math.round(1000 * data.duration / 2)) + // console.log('start zoon', Math.round(1000 * data.duration / 2)) + + for (var i=1; i