alvarotrigo / alvarotrigo/fullPage.js

YouTube API not responding as expected

オープン
#2,748 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る
Help needed
主要言語
JavaScript
スター
35.4k
フォーク
7.1k
PR マージ指標
30日以内にマージされた PR はありません

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。