Skip to content

Commit

Permalink
still testing on Safari 11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stamat committed Nov 13, 2023
1 parent c24f8a9 commit 742aeb0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
14 changes: 5 additions & 9 deletions jquery.youtube-background.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jquery.youtube-background.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jquery.youtube-background.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/lib/video-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class VideoBackground extends SuperVideoBackground {
const playerElement = document.createElement('video');
playerElement.setAttribute('playsinline', '');
if (this.params.loop) playerElement.setAttribute('loop', '');

console.log(this.type, this.params.autoplay, this.params['always-play'], this.isIntersecting, this.params.autoplay && (this.params['always-play'] || this.isIntersecting))
if (this.params.autoplay && (this.params['always-play'] || this.isIntersecting)) playerElement.setAttribute('autoplay', '');
if (this.muted) playerElement.setAttribute('muted', '');
if (this.params['lazyloading']) playerElement.setAttribute('loading', 'lazy');
Expand Down
12 changes: 4 additions & 8 deletions src/video-backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export class VideoBackgrounds {
if (!element) return;
if (element.hasAttribute('data-vbg-uid')) return;

if (!params) params = {};
if (!this.intersectionObserver) params['always-play'] = true;
if (!this.intersectionObserver) {
if (!params) params = {};
params['always-play'] = true;
}

const link = element.getAttribute('data-youtube') || element.getAttribute('data-vbg');
const vid_data = this.getVidID(link);
Expand Down Expand Up @@ -106,12 +108,6 @@ export class VideoBackgrounds {

if (!this.index[uid].params['always-play'] && this.intersectionObserver) {
this.intersectionObserver.observe(element);
} else {
this.index[uid].isIntersecting = true;

element.addEventListener('youtube-background-ready', () => {
if (this.index[uid].player && this.index[uid].params.autoplay) this.index[uid].softPlay();
}, { once: true });
}
}

Expand Down

0 comments on commit 742aeb0

Please sign in to comment.