Skip to content

Refactor overlay logic #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions injected/src/features/duckplayer/video-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,11 @@ export class VideoOverlay {
*/
const videoElement = document.querySelector(this.settings.selectors.videoElement);
const targetElement = document.querySelector(this.settings.selectors.videoElementContainer);
let drawerTargetElement;

if (!videoElement || !targetElement) {
return null;
}

if (this.isDrawerVariant()) {
drawerTargetElement = document.querySelector(/** @type {string} */ (this.settings.selectors.drawerContainer));
}

/**
* If we get here, it's a valid situation
*/
Expand Down Expand Up @@ -227,19 +222,22 @@ export class VideoOverlay {
this.stopVideoFromPlaying();

if (this.environment.layout === 'mobile') {
if (this.isDrawerVariant() && drawerTargetElement) {
this.appendMobileDrawer(targetElement, drawerTargetElement, params);
} else {
this.appendMobileOverlay(targetElement, params);
if (this.shouldShowDrawerVariant()) {
const drawerTargetElement = document.querySelector(/** @type {string} */ (this.settings.selectors.drawerContainer));
if (drawerTargetElement) {
return this.appendMobileDrawer(targetElement, drawerTargetElement, params);
}
}
} else {
this.appendDesktopOverlay(targetElement, params);

return this.appendMobileOverlay(targetElement, params);
}

return this.appendDesktopOverlay(targetElement, params);
}
}
}

isDrawerVariant() {
shouldShowDrawerVariant() {
return this.settings.videoDrawer?.state === 'enabled' && this.settings.selectors.drawerContainer;
}

Expand Down
Loading