Unbreak showing popup on hover

This commit is contained in:
Tamius Han 2024-12-27 23:12:41 +01:00
parent fe336122e0
commit 67f848a9ee
4 changed files with 65 additions and 45 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div <div
class="context-spawn" class="context-spawn uw-ui-area"
style="z-index: 1000;" style="z-index: 1000;"
v-if="!triggerZoneEditorVisible" v-if="!triggerZoneEditorVisible"
> >
@ -14,14 +14,14 @@
<div <div
v-if="contextMenuActive || settingsInitialized && uwTriggerZoneVisible && !isGlobal" v-if="contextMenuActive || settingsInitialized && uwTriggerZoneVisible && !isGlobal"
class="context-spawn uw-clickable" class="context-spawn uw-clickable uw-ui-area"
style="z-index: 1001" style="z-index: 1001"
@mouseenter="preventContextMenuHide()"
@mouseleave="allowContextMenuHide()"
> >
<GhettoContextMenu <GhettoContextMenu
alignment="right" class="uw-menu" alignment="right" class="uw-menu"
@mouseenter="newFeatureViewUpdate('uw6.ui-popup')" @mouseenter="() => {preventContextMenuHide(); newFeatureViewUpdate('uw6.ui-popup')}"
@mouseleave="allowContextMenuHide()"
> >
<template v-slot:activator> <template v-slot:activator>
<div class="context-item"> <div class="context-item">
@ -151,7 +151,7 @@
<div <div
v-if="settingsInitialized && uwWindowVisible" v-if="settingsInitialized && uwWindowVisible"
class="uw-window flex flex-col uw-clickable" class="uw-window flex flex-col uw-clickable uw-ui-area"
:class="{'fade-out': uwWindowFadeOut}" :class="{'fade-out': uwWindowFadeOut}"
> >
<PlayerUIWindow <PlayerUIWindow
@ -168,17 +168,16 @@
<div <div
v-if="triggerZoneEditorVisible" v-if="triggerZoneEditorVisible"
class="context-spawn" class="context-spawn uw-ui-area"
style="z-index: 1000; border: 2px dashed red; overflow: hidden;" style="z-index: 1000; border: 2px dashed red; overflow: hidden;"
> >
<TriggerZoneEditor <TriggerZoneEditor
class="uw-clickable"
:settings="settings" :settings="settings"
:eventBus="eventBus"
:playerDimensions="playerDimensions" :playerDimensions="playerDimensions"
> >
</TriggerZoneEditor> </TriggerZoneEditor>
</div> </div>
</template> </template>
<script> <script>
@ -393,13 +392,22 @@ export default {
'start-trigger-zone-edit', 'start-trigger-zone-edit',
{ {
function: () => { function: () => {
console.log('Showing trigger zone editor!');
this.triggerZoneEditorVisible = true; this.triggerZoneEditorVisible = true;
this.uwWindowVisible = false; this.uwWindowVisible = false;
} }
} }
); );
this.eventBus.subscribe(
'finish-trigger-zone-edit',
{
function: () => {
this.triggerZoneEditorVisible = false;
this.showUwWindow('playerUiSettings');
}
}
);
this.sendToParentLowLevel('uwui-get-role', null); this.sendToParentLowLevel('uwui-get-role', null);
this.sendToParentLowLevel('uwui-get-theme', null); this.sendToParentLowLevel('uwui-get-theme', null);
@ -544,13 +552,11 @@ export default {
background-color: rgba(0,0,0,0.85) !important; background-color: rgba(0,0,0,0.85) !important;
} }
</style> </style>
<style lang="scss" src="./src/res-common/panels.scss" scoped module></style>
<style lang="scss" src="./src/res-common/common.scss" scoped module></style>
<style lang="scss" scoped> <style lang="scss" scoped>
@import 'res/css/uwui-base.scss';
@import 'res/css/colors.scss';
@import 'res/css/font/overpass.css';
@import 'res/css/font/overpass-mono.css';
@import 'res/css/common.scss';
@import './src/res-common/_variables';
.uw-hover { .uw-hover {
position: absolute; position: absolute;
@ -670,4 +676,18 @@ export default {
border: 4px solid #fa4; border: 4px solid #fa4;
} }
.debug-1 {
border: 1px solid yellow;
&:hover {
background-color: rbba(255,255,0,0.5);
}
}
.debug-2 {
border: 1px solid blue;
&:hover {
background-color: rbba(0,0,255,.5);
}
}
</style> </style>

View File

@ -117,11 +117,11 @@
v-if="selectedTab === 'about'" v-if="selectedTab === 'about'"
> >
</AboutPanel> </AboutPanel>
<ResetBackupPanel <!-- <ResetBackupPanel
v-if="selectedTab === 'resetBackup'" v-if="selectedTab === 'resetBackup'"
:settings="settings" :settings="settings"
> >
</ResetBackupPanel> </ResetBackupPanel> -->
</div> </div>
</div> </div>
</div> </div>
@ -171,7 +171,7 @@ export default {
// {id: 'debugging', label: 'Debugging', icon: 'bug-outline' } // {id: 'debugging', label: 'Debugging', icon: 'bug-outline' }
{id: 'changelog', label: 'What\'s new', icon: 'alert-decagram' }, {id: 'changelog', label: 'What\'s new', icon: 'alert-decagram' },
{id: 'about', label: 'About', icon: 'information-outline'}, {id: 'about', label: 'About', icon: 'information-outline'},
{id: 'resetBackup', label: 'Reset and backup', icon: 'file-restore-outline'}, // {id: 'resetBackup', label: 'Reset and backup', icon: 'file-restore-outline'},
], ],
selectedTab: 'extensionSettings', selectedTab: 'extensionSettings',
BrowserDetect: BrowserDetect, BrowserDetect: BrowserDetect,

View File

@ -6,12 +6,16 @@ export default {
* the content script. * the content script.
*/ */
document.addEventListener('mousemove', (event) => { document.addEventListener('mousemove', (event) => {
this.handleProbe({ this.handleProbe(
coords: { {
x: event.clientX, coords: {
y: event.clientY x: event.clientX,
} y: event.clientY
}, this.origin); },
isCompanion: true,
},
this.origin
);
}); });
}, },
data() { data() {
@ -74,6 +78,7 @@ export default {
*/ */
let isClickable = false; let isClickable = false;
let isOverTriggerZone = false; let isOverTriggerZone = false;
let isOverUIArea = false;
const elements = document.elementsFromPoint(eventData.coords.x, eventData.coords.y); const elements = document.elementsFromPoint(eventData.coords.x, eventData.coords.y);
for (const element of elements) { for (const element of elements) {
@ -83,6 +88,9 @@ export default {
if (element.classList?.contains('uw-ui-trigger')) { if (element.classList?.contains('uw-ui-trigger')) {
isOverTriggerZone = true; isOverTriggerZone = true;
} }
if (element.classList?.contains('uw-ui-area')) {
isOverUIArea = true;
}
} }
this.triggerZoneActive = isOverTriggerZone; this.triggerZoneActive = isOverTriggerZone;
@ -91,18 +99,22 @@ export default {
// but don't show the trigger zone behind an active popup // but don't show the trigger zone behind an active popup
if ( if (
eventData.canShowUI eventData.canShowUI
&& (this.settings.active.ui.inPlayer.activation !== 'player' || isOverTriggerZone) && (this.settings.active.ui.inPlayer.activation === 'player' ? isOverUIArea : isOverTriggerZone)
) { ) {
if (! this.uwWindowVisible) { if (! this.uwWindowVisible) {
this.uwTriggerZoneVisible = true; this.uwTriggerZoneVisible = true;
clearTimeout(this.uwTriggerZoneTimeout); clearTimeout(this.uwTriggerZoneTimeout);
this.uwTriggerZoneTimeout = setTimeout( this.uwTriggerZoneTimeout = setTimeout(
() => this.uwTriggerZoneVisible = false, () => {
250 this.uwTriggerZoneVisible = false;
// this.$forceRefresh();
},
750
); );
} }
} else { } else {
this.uwTriggerZoneVisible = false; // console.log('[UI] hiding UI because conditions were not met. canShowUI:', eventData.canShowUI, 'isOverTriggerZone', isOverTriggerZone);
// this.uwTriggerZoneVisible = false;
} }
window.parent.postMessage( window.parent.postMessage(

View File

@ -107,12 +107,12 @@ class UI {
} }
const rect = this.uiIframe.getBoundingClientRect(); const rect = this.uiIframe.getBoundingClientRect();
const offsets = { const offsets = {
top: window.scrollY + rect.top, top: window.scrollY + rect.top,
left: window.scrollX + rect.left left: window.scrollX + rect.left
}; };
const coords = { const coords = {
x: event.pageX - offsets.left, x: event.pageX - offsets.left,
y: event.pageY - offsets.top, y: event.pageY - offsets.top,
@ -231,12 +231,12 @@ class UI {
* * player element () * * player element ()
* * uwui-clickable element * * uwui-clickable element
*/ */
canShowUI(coords) { canShowUI() {
const playerCssClass = 'uw-ultrawidify-player-css'; const playerCssClass = 'uw-ultrawidify-player-css';
const result = { const result = {
playerDimensions: undefined, playerDimensions: undefined,
canShowUI: false canShowUI: false,
} }
if (this.playerData?.dimensions) { if (this.playerData?.dimensions) {
@ -251,22 +251,10 @@ class UI {
// fullscreen mode unless watching videos) // fullscreen mode unless watching videos)
result.playerDimensions.width < window.screen.width * (this.uiSettings.inPlayer.minEnabledWidth ?? 0) result.playerDimensions.width < window.screen.width * (this.uiSettings.inPlayer.minEnabledWidth ?? 0)
) { ) {
result.canShowUI = false;
return result; return result;
} }
const elements = document.elementsFromPoint(coords.x, coords.y); result.canShowUI = true;
for (const element of elements) {
if (
element instanceof HTMLVideoElement
|| element.classList.contains(playerCssClass)
) {
result.canShowUI = true;
return result;
}
}
return result; return result;
} }