react-kenburns-view

May 25, 2026 · View on GitHub

ISC License npm Website

About

Ken Burns effect—slow zoom and pan over still images—for React web applications. Drop in a component, pass an image URL and size, and get smooth motion for heroes, galleries, or slideshows.

Lightweight: No animation library. Uses CSS transforms and requestAnimationFrame. Each instance uses randomized timing and pan direction so multiple images don’t move in lockstep.

For React Native, see react-native-kenburns-view.

Installation

npm install react-kenburns-view

Peer dependencies: React 17+ and React DOM 17+.

Demo

The interactive demo lives in react-library-demos under react-kenburns-view/. See that folder's README for setup (clone both repos as siblings, then npm install and npm run dev).

Usage

import KenBurnsView from 'react-kenburns-view';

function Hero() {
  return (
    <KenBurnsView
      width={1200}
      height={600}
      src="https://example.com/photo.jpg"
      alt="Hero"
      duration={15000}
      zoomStart={1}
      zoomEnd={1.2}
      panX={0.08}
      panY={0.08}
    />
  );
}

API (props)

PropTypeRequiredDescription
widthnumberYesContainer width (px).
heightnumberYesContainer height (px).
srcstringYesImage URL.
altstringNoAlt text for the image.
placeholderstringNoPlaceholder image URL (optional).
autoStartbooleanNoStart animation on mount. Default: true.
durationnumberNoFull cycle duration (ms). Default: 20000.
zoomStartnumberNoStart scale. Default: 1.
zoomEndnumberNoEnd scale. Default: 1.3.
panXnumberNoHorizontal pan (fraction of width). Default: 0.1.
panYnumberNoVertical pan (fraction of height). Default: 0.1.
classNamestringNoCSS class for the outer container.
styleobjectNoInline styles for the outer container.
childrennodeNoRendered inside the image layer.

Ref API

You can control the animation via a ref:

const ref = useRef();

// Start (or restart) the animation
ref.current?.start();

// Stop the animation
ref.current?.stop();

// Stop and reset progress to 0
ref.current?.reset();

License

ISC

Feedback

Website: nimila.online
Email: nimilahiran@gmail.com
X/Twitter: @nHiRanZ