Bounce it

By alexdmotoc · Web · React 19.3.1 · Published 22 November 2026

1 like Watch how it was written Remix Report

Code

import { useRef } from "react";

export default function Bit() {
  const ball = useRef(null);

  const bounce = () =>
    ball.current.animate(
      [
        { transform: "translateY(0)", easing: "ease-out" },
        { transform: "translateY(-250px)", easing: "ease-out" },
        { transform: "translateY(0)", easing: "ease-out" },
      ],
      800,
    );

  return (
    <div style={{ display: "grid", placeItems: "center", alignContent: "end", gap: 30, height: "90vh" }}>
      <div ref={ball} style={{ width: 80, height: 80, borderRadius: "50%", background: "tomato" }} />
      <button onClick={bounce}>Bounce</button>
    </div>
  );
}

© 2026 alexdmotoc. Published under the MIT licence: you may copy and change this code if you keep this credit.

Comments (0)

No comments yet.

Sign in to like or comment.