К основному содержанию
правило CX Codex

control-target-sync — правило для Claude Code

Правило control-target-sync связывает контрол и целевой элемент в одной сцене: скраб значения и поворот кнопки идут в одном кадре. Пригодится в демо редакторов и инспекторов.

MIT ★ 328 обновлён 2026-10-29

Установить в Claude Code · Вручную: положить файлы Все способы и платформы ↓
.claude/rules/control-target-sync.md
Открыть на GitHub

Что делает control-target-sync

Правило связывает контрол и целевой элемент так, чтобы они менялись в одном кадре: скрабят значение, а кнопка поворачивается; правят текст в поле, а иконки меняют размер. Рецептов два, оба на GSAP. При непрерывном скрабе readout-твин и твин цели ставятся на одну метку таймлайна с одинаковыми duration и ease: числовой прокси через onUpdate пишет в textContent, второй твин ведёт rotation, x или scale. При дискретных шагах один массив пороговых состояний хранит и строку readout, и значение свойства цели, а общий драйвер применяет активное состояние.

Панели с числом нужны font-variant-numeric: tabular-nums и фиксированная min-width не меньше самого длинного значения. Без них край панели дёргается на каждой смене цифр — это первое, что ломается в такой сцене. В вариантах: выбор из дропдауна с мгновенной подстановкой (твин между строками единиц читается как поломка), перетаскивание ручки кривой с отложенным повтором на цели и обратная связка, где панель показывает состояние цели.

Примеры собираются на таймлайне GSAP через tl.addLabel и gsap.set.

Какие задачи решает

  • связать скраб ползунка и поворот кнопки в одном кадре
  • показать правку класса и в панели, и на превью-иконках
  • собрать дискретные шаги из одного массива состояний без рассинхрона
  • убрать дёрганье панели при смене цифр в readout
  • отрепетировать повтор анимации цели после правки кривой

Примеры запросов агенту

  • Сделай сцену, где я скраблю Rotation, а #target-button поворачивается в том же кадре, по правилу control-target-sync.
  • Свяжи набор класса в поле с масштабом превью-иконок через один массив пороговых состояний.
  • Поставь tabular-nums и фиксированную min-width на readout Rotation, чтобы панель не дёргалась.

Как установить control-target-sync

Вручную: положить файлы

.claude/rules/control-target-sync.md

Поле paths во frontmatter ограничивает файлы

По шагам, с командами для каждой платформы: AGENTS.md и CLAUDE.md: что это, кто читает и какой выбрать

Вопросы о control-target-sync

Как установить control-target-sync в Claude Code?

Создайте в проекте файл .claude/rules/control-target-sync.md и поместите в него текст правила.

Что делает control-target-sync?

Задаёт связку контрола и цели: оба твина ставятся на одну метку таймлайна с одинаковыми длительностью и изингом, поэтому значение и отклик меняются в одном кадре.

Нужен ли GSAP?

Да, рецепты правила построены на таймлайне GSAP: tl.addLabel, tl.to и gsap.set для дискретных шагов.

Исходный текст

control-target-sync.md · MIT
---
name: control-target-sync
description: The live-sync couple — a scrubbed/typed/picked control drives a second element's property in the SAME beat. Readout tween + target transform tween share one timeline label (continuous scrub), or one threshold state array carries both sides (discrete steps). Makes "change this, watch it change" read as causality.
metadata:
  tags: control, scrub, live-sync, mirror, panel, editor, couple, readout, ui
---

# Control-Target Sync

THE live-editing move: an inspector/editor control is manipulated — a value scrubbed, a field retyped, a dropdown picked — and a **bound second element answers in the same frame**. The button rotates WHILE the rotation value scrubs; icons resize PER KEYSTROKE. The persuasion is causality — one gesture, two surfaces changing together — and this rule is the coupling contract that produces it.

Nearest precedent is [reactive-displacement.md](reactive-displacement.md): that rule also derives two elements' motion from one source, but it is **collision physics** — an entering intruder displaces an exiting victim, once, as a transition, and the victim leaves. This rule is a **live editing mirror**: the control is manipulated repeatedly across several beats, the target answers every time, and both sides hold the stage throughout. The numeric readout rides [counting-dynamic-scale.md](counting-dynamic-scale.md)'s proxy pattern; discrete steps ride [discrete-text-sequence.md](discrete-text-sequence.md)'s threshold pattern — what this rule adds is the law that binds either of them to the target.

## How It Works

An **edit beat** is a set of concurrent tweens at ONE timeline label: `tl.addLabel("edit1", …)`, then the **readout tween** (numeric proxy + `onUpdate` writing `textContent` only) and the **target transform tween** (`rotation` / `x` / `y` / `scale` to the same endpoint), both placed at the label with the same **duration** and **ease**. The two motions are two projections of one gesture — value at 40% ⇒ target at 40%, on every frame, under any seek. That mathematical lockstep reads as "the panel is editing the page," not "two animations happen to overlap."

For **discrete edits** (per-keystroke retypes, dropdown picks, unit snaps) the couple steps instead of glides: a single threshold state array carries BOTH sides — each state holds the readout text AND the target's property value — and one driver applies whichever state is active. Both sides read from the same state object, so they cannot desync.

Chain 2–4 edit beats with short holds between, and end on a **landed** edit — the last value applied and holding, never a tooltip with the dropdown unopened.

## Recipe

```html
<!-- Bipartite by construction: target surface + inspector panel share the frame.
     Every scrubbed readout gets `font-variant-numeric: tabular-nums` and a fixed
     min-width (≥ the longest value) or the panel edge jitters as digits change. -->
<div class="target-surface">
  <div class="target-button" id="target-button">{buttonLabel}</div>
  <div class="preview-row">
    <div class="preview-icon">{iconA}</div>
    …
  </div>
</div>
<div class="panel">
  <div class="field-row">
    <span>Rotation</span><span class="field-value" id="rotation-readout">0°</span>
  </div>
  <div class="field-row">
    <span>Class</span><span class="field-value mono" id="class-readout">text-1xl</span>
  </div>
</div>
```

```js
// ---- Continuous couple: ONE label; both tweens share duration AND ease ----
tl.addLabel("edit1", EDIT1_AT);
const rotState = { v: 0 };
const rotReadout = document.getElementById("rotation-readout");
tl.to(
  rotState,
  {
    v: ROT_TARGET,
    duration: SCRUB_DUR,
    ease: SCRUB_EASE,
    onUpdate: () => {
      rotReadout.textContent = `${Math.round(rotState.v)}°`;
    },
  },
  "edit1",
);
tl.to(
  "#target-button",
  { rotation: ROT_TARGET, duration: SCRUB_DUR, ease: SCRUB_EASE },
  "edit1", // same label — the mirror answers in the same frame
);

// ---- Discrete couple: ONE state array carries BOTH sides ----
const STEPS = [
  { t: 0.0, text: "text-1xl", scale: 1.0 }, // must equal the initial state
  { t: 0.4, text: "text-4xl", scale: 1.9 },
  { t: 1.0, text: "text-xl", scale: 0.85 }, // backspace
  { t: 1.35, text: "text-2xl", scale: 1.3 }, // lands
];
const stepAt = (time) => [...STEPS].reverse().find((s) => time >= s.t) ?? STEPS[0];

tl.addLabel("edit3", EDIT3_AT);
const classReadout = document.getElementById("class-readout");
const stepDriver = { t: 0 };
let lastStep = null;
tl.to(
  stepDriver,
  {
    t: STEPS_TOTAL,
    duration: STEPS_TOTAL,
    ease: "none",
    onUpdate: () => {
      const s = stepAt(stepDriver.t);
      if (s !== lastStep) {
        classReadout.textContent = s.text; // control steps
        gsap.set(".preview-icon", { scale: s.scale }); // target steps — same state object
        lastStep = s;
      }
    },
  },
  "edit3",
);
```

## Variations

- **Dropdown pick → instant conversion (self-conversion)** — the pick converts the panel's own readout in place (`tl.set("#padding-readout", { textContent: "6 px" }, "pick")`); control and target collapse into one element. Compose the dropdown from neighbors: menu pops via [spring-pop-entrance.md](spring-pop-entrance.md), row hover-stepping via [dynamic-content-sequencing.md](dynamic-content-sequencing.md). The conversion must be an INSTANT snap — tweening between unit strings reads as broken, and instantness is the feature being sold.
- **Easing-handle drag → target re-animates (deferred mirror)** — the edit authors a _behavior_, so the mirror is a **replay**, not a concurrent transform: beat 1 drags the handle (handle tween + coords readout), then at a later label the target performs its motion with the newly-authored curve (`tl.fromTo("#toggle-knob", { x: 0 }, { x: KNOB_TRAVEL, duration: REPLAY_DUR, ease: AUTHORED_EASE }, "replay")`), often under a zoom-out ([viewport-change.md](viewport-change.md)). The one sanctioned case where the response is not in the gesture's beat; the replay must still be unmistakably the edited parameter.
- **Read-sync mirror (reverse direction)** — the gesture happens ON the target (hovering swatches, selecting an element) and the PANEL readout is the bound side. Same discrete contract — one state array of `{ t, hoverTarget, readout }` drives both the highlight and the text.
- **Color couple** — the readout counts (`0 → 80`) while the target's `backgroundColor` tweens between two palette stops at the same label. Keep it two fixed stops (GSAP interpolates); never derive per-frame hex strings by hand.

## Values

| token                | range                           | notes                                                                                                                                 |
| -------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| SCRUB_DUR            | 0.8–1.6 s                       | the viewer must see BOTH sides move — under ~0.6 s the mirror registers subconsciously at best                                        |
| SCRUB_EASE           | `power1.inOut` / `power2.inOut` | shared verbatim by both tweens. Never `back.out` / `elastic.out` — an overshooting value reads as a broken hinge; the readout is data |
| edit endpoints       | visible but plausible           | −10° tilt, 38 px shift, 1xl → 4xl → 2xl; a 2° rotation doesn't demo anything                                                          |
| HOLD_BETWEEN         | 0.3–0.8 s                       | each landed value gets a breath; below 0.3 s the beats smear into one gesture                                                         |
| BEAT_COUNT           | 2–4                             | one edit is a moment, not a demo; past 4 the shot reads as a settings tour                                                            |
| STEP gaps (discrete) | 0.15–0.5 s                      | keystroke pacing per discrete-text-sequence; first state must equal the on-load state                                                 |
| VALUE_MIN_WIDTH      | ≥ longest value's width         | without it the panel edge jitters as digit counts change                                                                              |

## Critical Constraints

- **One label, one gesture** — readout tween and target tween share position, duration, AND ease; never sequence readout-then-target, and never stagger the target behind the readout even by 0.1 s — a delayed response reads as an animation following an edit, not a bound surface. A mismatched ease desyncs the mirror mid-tween even when endpoints agree.
- **Discrete steps share one state object** — both sides read the same array entry, so desync is impossible by construction; first entry mirrors the initial DOM state.
- **The readout is data** — no overshoot, no bounce on the settle; the target may carry the gesture's ease but lands exactly on the edited value.
- **Co-visibility is load-bearing** — control and target share the frame for every edit beat; a camera move must never crop the mirror out (punch-and-return around the beats, not through them).
- **`tabular-nums` + fixed `min-width`** on every scrubbed readout; `onUpdate` is O(1) — text writes only, discrete drivers guard writes with a last-state check.
- **End on a landed edit** — the final beat resolves with the value applied and holding (or the deferred-mirror replay); never mid-gesture or on an unopened menu.
- **The gesture's actor is a separate rule** — cursor glide, grab-cursor flip, and click feedback come from the cursor rules; this rule owns only the couple.

## See also

`cursor-click-ripple` / `context-sensitive-cursor` (the hand performing the gesture) · `counting-dynamic-scale` (the readout half alone, when there is no bound target) · `discrete-text-sequence` (retypes inside the control field) · `spring-pop-entrance` (dropdowns/chrome around the couple) · `multi-phase-camera` (punch-and-return framing) · `chart-scrub-readout` (the sibling READ direction — a scrub interrogates a chart instead of editing a target).

© coco-research · MIT · coco-research/coco

Похожие правила IDE

Все правила IDE по теме «Фронтенд и UI» →
gsap-timeline greensock Скилл gsap-timeline для Claude Code помогает собирать последовательности GSAP-анимаций и управлять таймингом и воспроизведением. Работает с многошаговыми и параллельными сценами. CX Codex +1 83 900установок dynamic-content-sequencing calesthio Правило dynamic-content-sequencing рассчитывает тайминги анимации на основе длины текста. Помогает собирать видеосцены и слайды без ручной подгонки секунд под каждый слайд. CX Codex +1 ★ 78 316звёзд репо gsap официальный HeyGen Справочник по GSAP с твинами, таймлайнами, easing и оптимизацией производительности. Подробно разбирает методы анимации, работу с media queries и готовые эффекты для HyperFrames. CX Codex GP ChatGPT +1 3установок coordinate-target-zoom calesthio Правило coordinate-target-zoom учит агента зумить в элемент, смещённый от центра экрана, комбинируя scale с обратным сдвигом — цель попадает в центр вьюпорта после масштабирования. CX Codex +1 ★ 78 316звёзд репо deconstruct raphaelsalaja Скилл deconstruct для Claude Code деконструирует анимации и интерфейсные взаимодействия в машину состояний и покадровый таймлайн. CX Codex +1 182установок cast AThevon Скилл cast для Claude Code оживляет интерфейс с помощью анимации и микровзаимодействий. Он изучает стек проекта и помогает продумать и реализовать визуальный эффект. CX Codex +1 1 600установок

Из того же набора82

Весь набор →
verify Команда verify сверяет готовую работу с планом или спецификацией и оценивает подтверждения по каждому требованию. Запустите её перед выпуском изменений. CX Codex +1 ★ 328звёзд репо particle-burst Правило particle-burst для Claude Code описывает создание конфетти, точек и текста, распадающегося на частицы. Положение частиц соответствует выбранному моменту таймлайна. CX Codex +1 ★ 328звёзд репо cursor-drag Правило cursor-drag задаёт физику анимации курсора при перетаскивании: синхронное движение с объектом-призраком, бросок в целевой слот, масштабирование за угол и автозаполнение строк. CX Codex +1 ★ 328звёзд репо product-design-super-intelligence Скилл product-design-super-intelligence для Claude Code собирает взгляды специалистов по продукту и дизайну, чтобы выбрать, что создавать, менять или сокращать. Обсуждает решение до запуска, а не оценивает его задним числом. CX Codex +1 ★ 328звёзд репо chromatic-glitch Правило chromatic-glitch задаёт паттерны сборки цифрового глитча на GSAP с детерминированным шумом и чётким возвратом в исходное состояние. CX Codex +1 ★ 328звёзд репо anchored-layout-expand Правило anchored-layout-expand для Claude Code описывает анимацию раскрывающейся панели, при которой содержимое ниже сдвигается вместе с её краем. Анимирует меню, карточки ввода и боковые панели. CX Codex +1 ★ 328звёзд репо chart-scrub-readout Правило chart-scrub-readout для Claude, которое превращает уже нарисованный график в инструмент: линия слежения едет по позиции скраба, маркер идёт по точкам, тултип показывает дату и значение. CX Codex +1 ★ 328звёзд репо multi-cursor-choreography Правило multi-cursor-choreography для Claude Code ставит несколько курсоров на общий canvas и задаёт им непересекающиеся действия. Подключается для анимации командной работы. CX Codex +1 ★ 328звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой