一键导入
page-transitions-barba
Add barba.js page transitions integrated with GSAP. Workflow: install → entry init → default transition → named per-route → hooks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add barba.js page transitions integrated with GSAP. Workflow: install → entry init → default transition → named per-route → hooks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Review existing Architecture Decision Records. Flag ADRs whose aging signals may have triggered given current state. Categorizes each as valid / aged / superseded and suggests follow-up actions.
Author an Architecture Decision Record (ADR). Captures decisions with implications beyond the current change — lasts months, affects multiple files, hard to reverse. Records context, alternatives considered, consequences, and aging signals so the decision can be revisited when conditions change.
4-phase loop-detection and recovery protocol. Fires when an agent detects it is stuck or repeating the same tool call with no progress — before tool-loop-detection circuit-breaks at 30 calls.
Socratic exploration of requirements before implementation. Refines spec through targeted questions. Use when user asks to 'explore options', 'refine requirements', or mentions 'unclear requirements'.
Generate structured changelog from git history. Groups commits by type, filters noise, produces Keep a Changelog format. Single source of truth — no /commands wrapper.
Generate pipe-delimited commits: Tipo|IdTarea|YYYYMMDD|Descripción. Single source of truth — no /commands wrapper.
| name | page-transitions-barba |
| description | Add barba.js page transitions integrated with GSAP. Workflow: install → entry init → default transition → named per-route → hooks. |
| version | 1.0.0 |
| when | {"keywords":["barba","page transition","smooth transition","route transition","animated navigation"]} |
| allowed-tools | ["Bash(npm install *)","Bash(pnpm add *)","Bash(bun add *)","Read","Write","Edit"] |
Wires @barba/core + GSAP into a non–App-Router project to deliver smooth page transitions. Barba intercepts navigation, swaps the data-barba="container" block, and runs leave / enter hooks where GSAP timelines live.
view-transitions opt-out), Remix Pages mode.unstable_ViewTransition (or CSS view-transition-name) instead — barba's DOM-swap fights React's reconciler.data-barba="wrapper" and the swappable block in data-barba="container". Barba does nothing without those.display: none → display: block. Use opacity + transform and toggle visibility via onComplete.afterEnter — barba does not restore scroll automatically.<main> (or the new page heading) in afterEnter for a11y; intercepted SPA navigation skips browser focus reset.prevent: 'all' then forgetting to handle external links — links to other origins need target="_blank" or an explicit rule.width, height, top) — kills FPS. Stick to transform + opacity.gsap.killTweensOf(...) on beforeLeave — orphaned tweens leak across routes.package.json + project files). If Next.js App Router → STOP and switch to View Transitions API.npm i @barba/core gsap (auto-detect pnpm-lock.yaml / bun.lockb and adjust).data-barba="wrapper" to the persistent shell and data-barba="container" data-barba-namespace="<route>" to the per-page block.main.ts / _app.tsx / entry.client.tsx, call initBarba() ONCE.from.namespace / to.namespace.afterEnter.src/lib/barba.tsimport barba from '@barba/core';
import gsap from 'gsap';
export function initBarba(): void {
barba.init({
debug: import.meta.env.DEV,
preventRunning: true,
transitions: [
// Default — applies when no named transition matches
{
name: 'fade',
async leave({ current }) {
gsap.killTweensOf(current.container);
await gsap.to(current.container, { opacity: 0, duration: 0.25, ease: 'power2.in' });
},
async enter({ next }) {
gsap.set(next.container, { opacity: 0 });
await gsap.to(next.container, { opacity: 1, duration: 0.35, ease: 'power2.out' });
},
},
// Named — only home → product
{
name: 'home-to-product',
from: { namespace: ['home'] },
to: { namespace: ['product'] },
async leave({ current }) {
await gsap.to(current.container, { y: -40, opacity: 0, duration: 0.3, ease: 'power3.in' });
},
async enter({ next }) {
gsap.set(next.container, { y: 40, opacity: 0 });
await gsap.to(next.container, { y: 0, opacity: 1, duration: 0.45, ease: 'power3.out' });
},
},
],
});
// Scroll restoration + focus management
barba.hooks.afterEnter(({ next }) => {
window.scrollTo({ top: 0, behavior: 'instant' });
const main = next.container.querySelector<HTMLElement>('main, h1');
main?.focus({ preventScroll: true });
});
// Defensive: kill stray tweens before each leave
barba.hooks.beforeLeave(({ current }) => {
gsap.killTweensOf(current.container);
});
}
| Stack | File | Call |
|---|---|---|
| Vite (vanilla) | src/main.ts | initBarba() after DOM ready |
| Next.js Pages Router | pages/_app.tsx | inside useEffect(() => { initBarba(); }, []) |
| Astro | src/layouts/Base.astro <script> | initBarba() (set viewTransitions: false) |
| Plain HTML | <script type="module"> at end of body | initBarba() |
<body data-barba="wrapper">
<header><!-- persistent --></header>
<main data-barba="container" data-barba-namespace="home" tabindex="-1">
<!-- page content -->
</main>
<footer><!-- persistent --></footer>
</body>
tabindex="-1" on the container is required for the focus-management hook above.
npm ls @barba/core gsap returns versions.[data-barba="wrapper"] and [data-barba="container"].<main>.debug: true flushes them).If app/ directory exists at the project root → DO NOT install barba. Use:
// app/layout.tsx — App Router native transitions
import { unstable_ViewTransition as ViewTransition } from 'react';
export default function Layout({ children }) {
return <ViewTransition>{children}</ViewTransition>;
}
Barba and the App Router router will both try to own navigation — symptoms: hydration mismatch, stuck transitions, leaked event listeners. There is no fix; pick one.