Skip to content

Commit

Permalink
fix: show video controls only on hover not when play starts (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparkier authored Jan 8, 2024
1 parent 9a4a807 commit c117e26
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/Demo/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@ import React from "react";
import styles from "./index.module.css";

export function Demo() {
const videoRef = React.useRef<HTMLVideoElement>(null);

return (
<div style={{ paddingBottom: "30px", paddingTop: "20px", textAlign: "center" }}>
<video controls autoPlay={true} loop className={styles.demo} muted>
<source src={require("@site/static/img/teaser.mp4").default} type="video/mp4"></source>
<div
style={{ paddingBottom: "30px", paddingTop: "20px", textAlign: "center" }}
>
<video
playsInline
autoPlay={true}
loop
className={styles.demo}
muted
onMouseOver={() => (videoRef.current.controls = true)}
onMouseOut={() => (videoRef.current.controls = false)}
ref={videoRef}
>
<source
src={require("@site/static/img/teaser.mp4").default}
type="video/mp4"
></source>
</video>
</div>
);
Expand Down

0 comments on commit c117e26

Please sign in to comment.