Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

dialog bg scroll prevent

Christian Fei103c8ab43ae6
diff --git a/index.html b/index.html
index 81fc058..061f9fc 100644
--- a/index.html
+++ b/index.html
@@ -141,6 +141,9 @@
);
opacity: 0.85;
}
+body.dialog-opened {
+ overflow: hidden;
+ }
</style>
<style>
body > header {
@@ -356,6 +359,22 @@
applyShowThumbnails(store.get(store.showThumbnailsKey))
applyFoldedChannels(store.get(store.foldedChannelsKey))
+ // observe dialog open/close and prevent body background scroll
+ observeDialogOpenPreventScroll($settings)
+ observeDialogOpenPreventScroll($videoPlayer)
+ observeDialogOpenPreventScroll($summaryModal)
+
+
+ function observeDialogOpenPreventScroll (dialog) {
+ new MutationObserver((mutationList, observer) => {
+ for (const mutation of mutationList) {
+ if (mutation.type === "attributes" && mutation.attributeName === 'open') {
+ document.body.classList[mutation.target.open ? 'add' : 'remove']('dialog-opened')
+ }
+ }
+ }).observe(dialog, { attributes: true, childList: true, subtree: true })
+ }
+
function applyShowThumbnails(showThumbnails) {
if (showThumbnails) {
document.body.classList.remove('hide-thumbnails')