Sync shared snapshot from 76bf591
This commit is contained in:
1 parent
6b84a5d27d
commit
ed3544acfe
3 files changed
+175
-1
No files matched your search
@@ -128,7 +128,10 @@
|
||||
controls?: boolean
|
||||
/** Renders the controls over the media surface or as a toolbar below it. */
|
||||
controlsPlacement?: 'overlay' | 'toolbar'
|
||||
/** Keep controls visible during playback. */
|
||||
/**
|
||||
* Fade the controls out after a few seconds of playback with no pointer or key activity over
|
||||
* the player. False keeps them visible while playing.
|
||||
*/
|
||||
autoHideControls?: boolean
|
||||
/** Whether clicks and key presses on the media surface control playback. */
|
||||
surfaceControls?: boolean
|
||||
@@ -192,6 +195,19 @@
|
||||
scheduleControlsHide()
|
||||
}
|
||||
|
||||
// The picture can sit on a canvas stacked above the frame, where the pointer never reaches the
|
||||
// frame's own elements. Pointer activity therefore counts anywhere inside the player's box.
|
||||
function handlePointerActivity(event: PointerEvent) {
|
||||
if (!controls || !playerFrame) return
|
||||
const bounds = playerFrame.getBoundingClientRect()
|
||||
const inside =
|
||||
event.clientX >= bounds.left &&
|
||||
event.clientX <= bounds.right &&
|
||||
event.clientY >= bounds.top &&
|
||||
event.clientY <= bounds.bottom
|
||||
if (inside) handlePlayerActivity()
|
||||
}
|
||||
|
||||
function togglePlayback() {
|
||||
if (controlsDisabled) return
|
||||
if (onTogglePlayback) {
|
||||
@@ -506,6 +522,8 @@
|
||||
<svelte:window
|
||||
onfullscreenchange={handleFullscreenChange}
|
||||
onkeydown={globalKeyboardControls ? handleKeydown : undefined}
|
||||
onpointermove={controls ? handlePointerActivity : undefined}
|
||||
onpointerdown={controls ? handlePointerActivity : undefined}
|
||||
/>
|
||||
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user