
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
react-dvd-screensaver
Advanced tools
DVD-era nostalgia in React.
npm i react-dvd-screensaver
To add a DVD screensaver effect to your React components, you can use the useDvdScreensaver hook. This hook provides you with references for both the parent (container) and the child (moving element), along with the number of times the child has hit the edges of the container.
import { useDvdScreensaver } from 'react-dvd-screensaver'
...
const { containerRef, elementRef } = useDvdScreensaver();
return (
<div ref={containerRef}>
<MyScreensaverComponent ref={elementRef} />
</div>
)
Pass the ref objects for parent and child to their respective components. Just remember to set the dimensions for both of them, where the childRef component naturally is smaller than the parent so there is room for it to move around.
| Hook returns following: | |
|---|---|
parentRef: refObject | Ref of the parent container component |
elementRef: refObject | Ref of the element to animate |
impactCount: number | Number of times the element has hit the container edges |
The hook accepts the following parameters:
| Option | Type | Description |
|---|---|---|
speed | number | Speed of the animation |
freezeOnHover | boolean | Whether to pause the animation on hover |
hoverCallback | Function | Callback function triggered on hover |
For easier implementation, you can also use the DvdScreensaver component to wrap any child component with the DVD screensaver effect.
import { DvdScreensaver } from 'react-dvd-screensaver'
...
return (
<div className="screensaver-container">
<DvdScreensaver>
<MyScreensaverComponent />
</DvdScreensaver>
</div>
)
The component inherits the parent container's dimensions by default, but you can also specify dimensions or styling directly via props.
| Prop | Type | Description |
|---|---|---|
className | string | Optional CSS class for the container |
freezeOnHover | boolean | Pause animation when hovered |
height | number | Optional height for the container |
width | number | Optional width for the container |
| `hoverCallback | Function | Callback function triggered on hover |
impactCallback | (count: number) => void | Callback function triggered on impact with edges |
speed | number | Speed of the animation |
FAQs
DVD-era nostalgia in React
The npm package react-dvd-screensaver receives a total of 1,571 weekly downloads. As such, react-dvd-screensaver popularity was classified as popular.
We found that react-dvd-screensaver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.