From fc6ab71bef157d39de7f7cbb3111592888559e59 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Oct 2021 10:38:25 +0100 Subject: [PATCH] add visible class --- app/static/js/ascroll.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index c018c95..2a06e06 100644 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -61,6 +61,11 @@ function onVisibilityChange(el, callback) { var visible = isElementInViewport(el); if (visible != old_visible) { old_visible = visible; + if (visible) { + el.classList.add('visible') + } else { + el.classList.remove('visible') + } if (typeof callback == 'function') { callback(visible); } @@ -208,8 +213,9 @@ function loadItem(config) { ascroll.appendChild(div) var frame = div.querySelector('.frame') document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) { - if (loaded && visible) + if (loaded && visible) { updatePlayer(video, frame, annotation['in'], annotation['out']) + } })) }) @@ -222,7 +228,6 @@ function loadItem(config) { } function loadEdit(config) { pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => { - console.log(response) var ascroll = document.querySelector('#ascroll') var loaded = false @@ -260,8 +265,9 @@ function loadEdit(config) { var frame = div.querySelector('.frame') document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) { var src = `${baseURL}/${annotation.id.split('/')[0]}/480p.webm` - if (loaded && visible) + if (loaded && visible) { updatePlayer(video, frame, annotation['in'], annotation['out'], src) + } })) })