Skip to content

Commit 2dd2212

Browse files
committed
fix: plyr controls querySelectorAll
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent bc40f67 commit 2dd2212

6 files changed

Lines changed: 19 additions & 8 deletions

File tree

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/viewer-init.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* extracted by css-entry-points-plugin */
2-
@import './init-x4ybIV8G.chunk.css';
2+
@import './init-DdG1tait.chunk.css';
33
@import './viewerAction-6cpbKhU6.chunk.css';
44
@import './NcActionButton-DyH89PpO.chunk.css';
55
@import './NcActionLink-Cay-IPuV.chunk.css';

js/viewer-init.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

js/viewer-init.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Audios.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,16 @@ export default {
9393
},
9494
},
9595
96-
mounted() {
96+
// for some reason the video controls don't get mounted to the dom until after the component (Videos) is mounted,
97+
// using the mounted() hook will leave us with an empty array
98+
updated() {
9799
// Prevent swiping to the next/previous item when scrubbing the timeline or changing volume
98-
[...this.$el.querySelectorAll('.plyr__controls__item')].forEach(control => {
100+
const plyrControls = this.$el.querySelectorAll('.plyr__controls__item')
101+
if (!plyrControls || !plyrControls.length) {
102+
return
103+
}
104+
105+
[...plyrControls].forEach(control => {
99106
if (!control?.addEventListener) {
100107
return
101108
}

src/components/Videos.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ export default {
117117
}
118118
},
119119
},
120+
120121
// for some reason the video controls don't get mounted to the dom until after the component (Videos) is mounted,
121122
// using the mounted() hook will leave us with an empty array
122-
123123
updated() {
124124
// Prevent swiping to the next/previous item when scrubbing the timeline or changing volume
125-
[...this.$el.querySelectorAll('.plyr__controls__item')].forEach(control => {
125+
const plyrControls = this.$el.querySelectorAll('.plyr__controls__item')
126+
if (!plyrControls || !plyrControls.length) {
127+
return
128+
}
129+
[...plyrControls].forEach(control => {
126130
if (control.getAttribute('data-plyr') === 'fullscreen') {
127131
control.addEventListener('click', this.hideHeaderAndFooter)
128132
}

0 commit comments

Comments
 (0)