Skip to main content
rule CX Codex

viewport-change — Claude Code rule: what it does, how to install

viewport-change — a rule that teaches the agent a virtual camera in GSAP scenes: zoom, pan and focus-lock on a moving element, all through one wrapper.

AGPL-3.0 ★ 78,316 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/viewport-change.md
Open on GitHub

What viewport-change does

This rule sets up a virtual camera for an HTML and GSAP scene. All scene content sits inside one .world block, and the agent moves that block opposite to the camera you want. Pan right and the block slides left. Zoom in and it gets scale above 1. To follow an element, the X offset is recalculated every frame.

Camera state lives in a cam object with scale, x and y. applyCamera() turns it into translate(x, y) scale(S), and a GSAP tween updates the object through onUpdate. CSS applies the scale first, so centering a target takes T = -offset × S. The rule ships HTML, CSS and a three-phase timeline skeleton, plus a scale table: 1.02 to 1.05 is barely noticeable, 1.5 to 2.5 fills the screen with the element.

The formula is specific to this rule. coordinate-target-zoom uses two nested wrappers and T = -offset, so copying one setup into the other pushes the target off center. For 2-3 discrete phases with drift there is a separate rule, multi-phase-camera. Placeholders such as {Brand} and HERO_FONT_SIZE need your own values.

What it helps with

  • zoom the camera onto the #cta button at the end of a clip
  • pan the whole frame right with one wrapper instead of moving each element
  • keep a moving cursor at a fixed screen X
  • combine two scale tweens into one compound zoom
  • pick a zoom strength from a scale table

Example prompts for the agent

  • Add a virtual camera to viewport-scene with the viewport-change rule and zoom in on #cta.
  • Make the camera follow .moving-cursor and hold it at a fixed screen X, following viewport-change.
  • Pan the scene right with a single transform on .world, per viewport-change.

How to install viewport-change

Manually: put the files in place

.claude/rules/viewport-change.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about viewport-change

How do I install viewport-change in Claude Code?

Put the rule file at .claude/rules/viewport-change.md.

What does viewport-change do?

It teaches the agent to fake zoom, pan and element-following. All scene content sits in one block, and the agent translates and scales that block as a whole.

How is viewport-change different from coordinate-target-zoom?

This rule uses one wrapper with translate(x, y) scale(S) and T = -offset × S. coordinate-target-zoom uses two nested wrappers with T = -offset, which fits better when scale and translate tween independently with a shared ease.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set101

The whole set →
orbit-3d-entry orbit-3d-entry sets up a GSAP animation where items flip in from 3D coordinates and transition into a continuous elliptical orbit around a center point. CX Codex +1 ★ 78,316repo stars motion-graphics motion-graphics is a Claude Code skill that creates short motion-led graphics, from animated headlines and charts to logo stings. For pieces without narration or live-action footage. CX Codex +1 ★ 78,316repo stars sine-wave-loop sine-wave-loop — a GSAP rule that gives a settled scene element light jitter, or one bounded breathing loop, driven by Math.sin once its entry animation ends. CX Codex +1 ★ 78,316repo stars avatar-cloud-network avatar-cloud-network guides the agent in creating an elliptical community reveal scene with a center hub and SVG lines. Built for social proof animations powered by GSAP. CX Codex +1 ★ 78,316repo stars coordinate-target-zoom coordinate-target-zoom — a rule that teaches the agent to zoom into an element displaced from viewport center by pairing scale with counter-translation — the target lands at center after the zoom. CX Codex +1 ★ 78,316repo stars ai-tracking-box ai-tracking-box generates an animated target bounding box with corner brackets and oscillating coordinates to simulate computer vision tracking in GSAP. CX Codex +1 ★ 78,316repo stars spring-pop-entrance The spring-pop-entrance rule describes a smooth scale-in for one element or a staggered group. Use it for interface elements that should arrive on screen without bouncing. CX Codex +1 ★ 78,316repo stars depth-scatter-assemble depth-scatter-assemble — a rule for scenes where glyphs, cards or logo pieces arrive out of a turning 3D cloud and land in a flat layout. The reverse also works. CX Codex +1 ★ 78,316repo stars

Project sponsors

Companies that keep this analytics open