|
|
@ -1,6 +1,6 @@ |
|
|
|
class Slide { |
|
|
|
constructor(slide, idx) { |
|
|
|
this.isInit = false |
|
|
|
this.isAudioLoaded = this.isVideoLoaded = false |
|
|
|
this.el = slide |
|
|
|
this.idx = idx |
|
|
|
this.duration = slide.dataset.duration |
|
|
@ -32,8 +32,8 @@ class Slide { |
|
|
|
container: this.videoContainer |
|
|
|
}) |
|
|
|
|
|
|
|
videoEmbed.on('init', (data) => { |
|
|
|
this.isVideoInit = true |
|
|
|
videoEmbed.on('loaded', () => { |
|
|
|
this.isVideoLoaded = true |
|
|
|
}) |
|
|
|
|
|
|
|
videoEmbed.on('playing', (positionData) => { |
|
|
@ -50,8 +50,8 @@ class Slide { |
|
|
|
container: this.audioContainer |
|
|
|
}) |
|
|
|
|
|
|
|
audioEmbed.on('init', (data) => { |
|
|
|
this.isAudioInit = true |
|
|
|
audioEmbed.on('loaded', () => { |
|
|
|
this.isAudioLoaded = true |
|
|
|
}) |
|
|
|
|
|
|
|
audioEmbed.on('playing', (positionData) => { |
|
|
@ -64,6 +64,19 @@ class Slide { |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
isReady() { |
|
|
|
console.log('isReady called'); |
|
|
|
if (this.video && this.audio) { |
|
|
|
return this.isVideoLoaded && this.isAudioLoaded |
|
|
|
} else if (this.video) { |
|
|
|
return this.isVideoLoaded |
|
|
|
} else if (this.audio) { |
|
|
|
return this.isAudioLoaded |
|
|
|
} else { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sendToBack() { |
|
|
|
this.el.style.zIndex = 0 |
|
|
|
return this |
|
|
@ -75,6 +88,7 @@ class Slide { |
|
|
|
} |
|
|
|
|
|
|
|
start() { |
|
|
|
console.log('called start', this.isReady()) |
|
|
|
if (this.zooms) { |
|
|
|
this.startZoom() |
|
|
|
} else if (this.video && this.video.length) { |
|
|
@ -174,7 +188,14 @@ function init() { |
|
|
|
} |
|
|
|
|
|
|
|
function go(idx) { |
|
|
|
if (!slides[idx].isReady()) { |
|
|
|
console.log('slide not ready'); |
|
|
|
return setTimeout(() => { |
|
|
|
go(idx) |
|
|
|
}, 250) |
|
|
|
} |
|
|
|
var old = current |
|
|
|
|
|
|
|
slides[current].sendToBack() |
|
|
|
slides[idx].bringToFront() |
|
|
|
current = idx |
|
|
|