nk-o / jarallax

Parallax scrolling for modern browsers

Home Page:https://jarallax.nkdev.info

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to pause the video when scrolling

mmttee opened this issue · comments

commented

Issue description:

I added play/pause buttons to control the video (as it's required by WCAG AA standards) but the problem occurs when the user had paused the video and try to scroll the page then the video starts playing automatically which I'm trying to prevent.

Anyone had this issue before, if so how did you solve it?

Version used:

(Did you try using the develop branch from GitHub? There's a chance your issue has already been addressed there)

1.12.2

Code to reproduce the issue (HTML blocks + JavaScript initialization)

When enabled option videoPlayOnlyVisible, video will be paused and played automatically

if ( self.options.videoPlayOnlyVisible ) {
const oldOnScroll = self.onScroll;
self.onScroll = function() {
oldOnScroll.apply( self );
if ( ! self.videoError && ( self.options.videoLoop || ( ! self.options.videoLoop && ! self.videoEnded ) ) ) {
if ( self.isVisible() ) {
video.play();
} else {
video.pause();
}
}
};
} else {
video.play();
}