Skip to main content
rule CX Codex

coordinate-target-zoom — Claude Code rule

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.

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/coordinate-target-zoom.md
Open on GitHub

What coordinate-target-zoom does

A bare scale > 1 on a wrapper pushes off-center content off-canvas. The rule defines a method to zoom into a chosen element: an outer wrapper scales the scene, an inner wrapper counters the target's offset with translate(x, y) equal to minus the target's displacement from viewport center. The formula is independent of zoom factor — the shift stays the same at 1.5×, 2× or 3×, as long as the outer wrapper's transform-origin is set to 50% 50%.

The rule requires measuring the element's real position via getBoundingClientRect once after font load — hand calculation works only for symmetric rows of equal-width cards, otherwise it yields the wrong sign. The measurement happens before timeline registration, inside an async setup. Without overflow: hidden on the scene wrapper, the rule breaks. Peak scale is capped so the target occupies no more than 88% of the frame — a two-pixel centering error at 3× zoom becomes six and shoves the element off-edge.

What it helps with

  • zoom into a card or chip off viewport center so it ends up in the middle of the frame
  • scale a non-centered element without pushing it beyond the viewport boundary
  • pair scale with compensating translate for focus animation on an offset target

Example prompts for the agent

  • Add a 2.5× zoom into target-card — it sits on the right, but needs to land at center.
  • Enlarge the third price out of four in a row, 5-second scene — element is offset right, measure its displacement.
  • Focus on #winner-badge — it's on the side, timeline should center it after zoom.

How to install coordinate-target-zoom

Manually: put the files in place

.claude/rules/coordinate-target-zoom.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 coordinate-target-zoom

How to install coordinate-target-zoom in Claude Code?

Place the rule file at .claude/rules/coordinate-target-zoom.md in your project root. Claude Code will pick it up automatically.

What does coordinate-target-zoom do?

The rule teaches the agent to zoom into an element displaced from viewport center by pairing scale with counter-translate — the target ends up centered. It needs two wrappers: the outer applies scale, the inner shifts content by minus the target's offset.

Do I need to hand-calculate the offset?

Only if the row is symmetric and all cards have equal width. For everything else, measure position via getBoundingClientRect after document.fonts.ready — the hand formula yields the wrong sign for asymmetric layouts, and the zoom will push the element off-frame.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set101

The whole set →
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 viewport-change 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. 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 ambient-glow-bloom ambient-glow-bloom defines code patterns for soft backdrop glow and light sweeps on key elements. Guides code assistants to write seek-safe GSAP timelines without infinite loops. CX Codex +1 ★ 78,316repo stars

Project sponsors

Companies that keep this analytics open