add visible class
This commit is contained in:
parent
ea1fcb110d
commit
fc6ab71bef
1 changed files with 9 additions and 3 deletions
|
@ -61,6 +61,11 @@ function onVisibilityChange(el, callback) {
|
||||||
var visible = isElementInViewport(el);
|
var visible = isElementInViewport(el);
|
||||||
if (visible != old_visible) {
|
if (visible != old_visible) {
|
||||||
old_visible = visible;
|
old_visible = visible;
|
||||||
|
if (visible) {
|
||||||
|
el.classList.add('visible')
|
||||||
|
} else {
|
||||||
|
el.classList.remove('visible')
|
||||||
|
}
|
||||||
if (typeof callback == 'function') {
|
if (typeof callback == 'function') {
|
||||||
callback(visible);
|
callback(visible);
|
||||||
}
|
}
|
||||||
|
@ -208,8 +213,9 @@ function loadItem(config) {
|
||||||
ascroll.appendChild(div)
|
ascroll.appendChild(div)
|
||||||
var frame = div.querySelector('.frame')
|
var frame = div.querySelector('.frame')
|
||||||
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
||||||
if (loaded && visible)
|
if (loaded && visible) {
|
||||||
updatePlayer(video, frame, annotation['in'], annotation['out'])
|
updatePlayer(video, frame, annotation['in'], annotation['out'])
|
||||||
|
}
|
||||||
|
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
@ -222,7 +228,6 @@ function loadItem(config) {
|
||||||
}
|
}
|
||||||
function loadEdit(config) {
|
function loadEdit(config) {
|
||||||
pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => {
|
pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => {
|
||||||
console.log(response)
|
|
||||||
var ascroll = document.querySelector('#ascroll')
|
var ascroll = document.querySelector('#ascroll')
|
||||||
var loaded = false
|
var loaded = false
|
||||||
|
|
||||||
|
@ -260,8 +265,9 @@ function loadEdit(config) {
|
||||||
var frame = div.querySelector('.frame')
|
var frame = div.querySelector('.frame')
|
||||||
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
||||||
var src = `${baseURL}/${annotation.id.split('/')[0]}/480p.webm`
|
var src = `${baseURL}/${annotation.id.split('/')[0]}/480p.webm`
|
||||||
if (loaded && visible)
|
if (loaded && visible) {
|
||||||
updatePlayer(video, frame, annotation['in'], annotation['out'], src)
|
updatePlayer(video, frame, annotation['in'], annotation['out'], src)
|
||||||
|
}
|
||||||
|
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue