player: use CSS :has() for volume slider hover (pure CSS solution)
This commit is contained in:
@@ -232,6 +232,7 @@ templ VideoPlayer(data WatchPageData) {
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div data-volume-wrap class="volume-wrap relative flex h-10 w-10 items-center justify-center overflow-visible">
|
<div data-volume-wrap class="volume-wrap relative flex h-10 w-10 items-center justify-center overflow-visible">
|
||||||
|
<span data-volume-bridge class="pointer-events-none absolute inset-x-0 bottom-full h-[calc(100%+100px)]"></span>
|
||||||
<div class="volume-panel pointer-events-none absolute bottom-[calc(100%+26px)] left-1/2 z-30 -translate-x-1/2 opacity-0 invisible transition-opacity">
|
<div class="volume-panel pointer-events-none absolute bottom-[calc(100%+26px)] left-1/2 z-30 -translate-x-1/2 opacity-0 invisible transition-opacity">
|
||||||
<input
|
<input
|
||||||
data-volume-range
|
data-volume-range
|
||||||
|
|||||||
@@ -502,13 +502,12 @@ const initPlayer = (): void => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
muteBtn?.addEventListener('mouseenter', () => {
|
muteBtn?.addEventListener('mouseenter', () => {
|
||||||
volumeWrap?.classList.add('show-volume')
|
muteBtn.classList.add('show-volume')
|
||||||
isHoveringVolume = true
|
isHoveringVolume = true
|
||||||
showControls()
|
showControls()
|
||||||
})
|
})
|
||||||
|
|
||||||
muteBtn?.addEventListener('mouseleave', () => {
|
muteBtn?.addEventListener('mouseleave', () => {
|
||||||
volumeWrap?.classList.remove('show-volume')
|
|
||||||
isHoveringVolume = false
|
isHoveringVolume = false
|
||||||
showControls()
|
showControls()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -84,8 +84,9 @@
|
|||||||
height: 130px;
|
height: 130px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.volume-wrap.show-volume .volume-panel,
|
.volume-wrap:has([data-mute]:hover) .volume-panel,
|
||||||
.volume-wrap.show-volume::before,
|
.volume-wrap:has([data-volume-bridge]:hover) .volume-panel,
|
||||||
|
.volume-wrap:has(.volume-panel:hover) .volume-panel,
|
||||||
.volume-wrap:focus-within .volume-panel,
|
.volume-wrap:focus-within .volume-panel,
|
||||||
.volume-panel:hover,
|
.volume-panel:hover,
|
||||||
.volume-panel:focus-within {
|
.volume-panel:focus-within {
|
||||||
@@ -94,7 +95,9 @@
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.volume-wrap.show-volume .volume-underline,
|
.volume-wrap:has([data-mute]:hover) .volume-underline,
|
||||||
|
.volume-wrap:has([data-volume-bridge]:hover) .volume-underline,
|
||||||
|
.volume-wrap:has(.volume-panel:hover) .volume-underline,
|
||||||
.volume-wrap:focus-within .volume-underline {
|
.volume-wrap:focus-within .volume-underline {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user