alvarotrigo / alvarotrigo/fullPage.js

YouTube API not responding as expected

Aberta
#2,748 9 comentários 0 reações 0 responsáveis Ver no GitHub
Help needed
Linguagem predominante
JavaScript
Estrelas
35.4k
Forks
7.1k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

### Description
This is a messy one with several issues...

I have a YouTube iFrame (managed by the YouTube JS API) in a Fullpage JS section. The video has been stretched to fill the entire section (height & width 100%). Some content in the other sections may be longer than the section height, which required me to enable the scrollOverflow for FullpageJS.

With the above set-up, I was not able to scroll away from the YouTube section, as the iframe seemed to be capturing the scroll event. So I created an 'overlay' div to cover the video and act as a 'surface' to scroll on.

The overlay div starts out displayed (in the JSFiddle below, I've coloured it red to better see it), then when you click it, it's hidden and the video starts playing. When the video is paused or ends, I want the overlay to reappear. I detect this with YouTube's onStateChange event listener. See line 11 of JSFiddle.

**Now, the following error only happens on mobile platforms or in JSFiddle. On regular desktop (Chrome, Firefox, IE, etc) it behaves fine. But...**

Something in Fullpage seems to be interfering with YouTube's onStateChange event listener and stops it from firing. This means the overlay cannot be re-applied and you're left stranded on the video slide. It's definitely Fullpage, because if you remove the call to Fullpage on line 23 of JSFiddle, the event listener works fine and the overlay behaves as expected. Also, strangely, YouTube's onReady event listener fires just fine. Hmm..

So:

1.) Anyone else come across this issue / a solution to it?
2.) Am I going the right way about tackling the underlying "scroll even captured by iframe" problem with an overlay, or has anyone else found a better solution?

### Link to isolated reproduction with no external CSS / JS
Reproduction of environment:
https://jsfiddle.net/rredfearn32/phcwa63w/56/

Site of original error:
http://dev.oxplore.surge.online/question-detail/602

### Steps to reproduce it
1. When overlay is in place, scroll freely between slides.
2. After you start playing a video, you are then unable to scroll away.
3. When you pause the video, the overlay does not appear like it should.

### Versions
Mobile Chrome on Android devices, JSFiddle

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.