私は、いくつかのビデオで縦にスクロールする長いWebページを持っています。 Media Element Playerを使用するとビデオは再生されますが、フルスクリーンモードにしてからフルスクリーンモードを終了すると、ページ上のビデオの位置に関係なく、ページは一番上に戻ります。私はそれを同じ場所に戻したい。ここで私が使用しているコードは次のとおりです。Media Element Player終了フルスクリーンスクロールの問題
var topPosition;
MediaElementPlayer.prototype.enterFullScreen_org =
MediaElementPlayer.prototype.enterFullScreen;
MediaElementPlayer.prototype.enterFullScreen = function() {
console.log('enter full screen');
this.enterFullScreen_org();
topPosition = window.pageYOffset;
console.log(topPosition);
}
MediaElementPlayer.prototype.exitFullScreen_org =
MediaElementPlayer.prototype.exitFullScreen;
MediaElementPlayer.prototype.exitFullScreen = function() {
console.log('exit full screen')
this.exitFullScreen_org();
ResetFullScreen();
}
function ResetFullScreen() {
console.log('top pos:', topPosition);
setTimeout(function() { window.scrollTo(0, topPosition) }, 500);
}
にconsole.logは「topPosition」の正しい値を示したが、window.scrollToはメソッドが機能するように表示されません。
これは動作しますが、何らかの理由でフルスクリーンを終了した後にdocument.body.scrollTopプロパティが機能しません。これは、全画面の入力/終了の前に動作しますが、後は動作しません。私はコンソールでテストしました。 –
それは本当に変だ...私はそれが以前に起こったことを見たことがない。私は考えることができるもう一つの方法を答えに加えるつもりです... – MineAndCraft12