add visible class

This commit is contained in:
j 2021-10-12 10:38:25 +01:00
parent ea1fcb110d
commit fc6ab71bef

View file

@ -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)
}
}))
})