一键导入
animation-and-motion
Use when building enter/leave transitions, layout animations, stagger effects, or spring-physics motion in pocopine components
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when building enter/leave transitions, layout animations, stagger effects, or spring-physics motion in pocopine components
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when turning a Claude Design (or any mockup/design) into a well-structured pocopine app — choosing app architecture (a store plus layout/leaf components), translating inline styles into Pine Stylekit, wiring icons and resizable regions, and verifying the result.
Use when working with the pocopine Pine icons feature — the `icon!` proc macro for compile-time Rust SVG embedding, or the `<pine-icon>` template primitive with `register_icons!` for tree-shaking-friendly template rendering.
Use when building styles with Pine Stylekit, the Pocopine-native utility-CSS compiler, or working with @theme tokens and CSS generation in Rust/WASM projects
Use when implementing authentication in pocopine apps — JWT verification, credentials, OAuth providers, session management, or guards
Use when defining background jobs, enqueueing work, configuring workers, or troubleshooting job execution in pocopine apps
Use when setting up or working with Pocopine's managed .client.ts modules for importing npm SDKs (Firebase, analytics, etc.) with typed Rust facades
| name | animation-and-motion |
| description | Use when building enter/leave transitions, layout animations, stagger effects, or spring-physics motion in pocopine components |
pocopine provides three layers of animation: CSS-class-based transitions on mount/unmount, layout animation (FLIP) for reorders, and programmatic WAAPI + spring physics via pine-motion.
Declarative (RFC-038 / RFC-039):
pp-transition="<preset>" — symmetric enter + leave (shorthand on element or #[component(transition = …)])pp-transition:in="<preset>" pp-transition:out="<preset>" — asymmetric (or transition_in / transition_out macro args)pp-transition:enter, :enter-start, :enter-end, :leave, :leave-start, :leave-end — six-phase class attributespp-flip — layout animation on any element; watches DOM mutations and FLIP-animates position shiftsanimate="flip" — keyed pp-for reorder animation on componentsdata-pp-motion="always" | "reduce" — per-element motion preference overridePreset names: fade, scale, fade-scale, zoom, slide-up, slide-down, slide-left, slide-right, collapse, none
Programmatic (pocopine::animate):
animate(el, keyframes, options) -> AnimationHandle — Web Animations API wrapperapply_preset(el, in_name, out_name) — stamp preset onto elementflip_from_snapshot(el, old_rect, opts) — manual FLIPenter_subtree_staggered(root, stagger_ms, on_done) — sequenced revealsmotion::effective_for(el) -> MotionPreference — read prefers-reduced-motionpine-motion (higher-level):
Spring::visual(duration_s, bounce) / Spring::physics(stiffness, damping, mass) — GPU-sampled springsEasing::Spring(s) / Easing::APPLE / Easing::EASE_OUT_QUAD — named + spring timingStagger::new(each_ms).from(Origin::Center) — stagger configdrag(el, DragConfig) — element-follows-pointer with momentum1. Component with default transition:
#[derive(Default, Serialize, Deserialize)]
#[component(template = "MyPanel.poco", transition = "fade-scale")]
pub struct MyPanel {
#[prop] pub open: bool,
}
Mount via pp-if and the fade-scale preset runs automatically. (RFC-038)
2. Six-phase class transition in template (hn/src/components/story_detail/StoryDetail.poco):
<div pp-transition:enter="pp-fade-enter"
pp-transition:enter-start="pp-fade-enter-start"
pp-transition:enter-end="pp-fade-enter-end"
pp-transition:leave="pp-fade-leave"
pp-transition:leave-start="pp-fade-leave-start"
pp-transition:leave-end="pp-fade-leave-end">
<!-- content -->
</div>
Author defines CSS classes; directive swaps them through enter/leave phases.
3. FLIP layout animation on list reorder:
<ul pp-flip-container>
<template pp-for="item in items" pp-key="item">
<li pp-flip>{item}</li>
</template>
</ul>
Registers each <li> for layout animation. On reorder, MutationObserver detects shift and animates position delta.
4. Programmatic WAAPI with spring (pine-motion):
use pine_motion::{animate, Spring};
animate(
&el,
&[("opacity", "0", "1"), ("transform", "scale(0.8)", "scale(1)")],
Spring::visual(0.3, 0.25).into_timing(), // sampled to linear(...) for GPU
);
pp-tx-<name>-base, -from, -to) stamped onto the six pp-transition:* attributes. The attribute names are fixed; customize durations/easing via CSS custom properties (--pp-tx-duration, --pp-tx-<name>-duration).data-pp-motion="always" on the element). WAAPI respects respect_motion_preference: true in AnimateOptions (default).pp-resize (ResizeObserver path deferred; see RFC-039 §7).pp-transition:enter completes, the base + end classes remain on the element to avoid flicker. They clear on the next enter() call or in leave().pocopine::animate::enter_subtree_staggered(root, 30, cb) directly; the #[component(stagger_ms = N)] macro arg is not yet implemented (RFC-039 §6).leave_subtree times out after 1000ms if a competing call cancels leaves; this keeps leaked clones from lingering indefinitely.crates/pocopine-core/src/directives/transition.rs — six-phase state machinecrates/pocopine-core/src/directives/flip.rs — pp-flip directivecrates/pocopine-core/src/animate/mod.rs — public API surfacecrates/pocopine-core/src/animate/motion.rs — prefers-reduced-motion detectioncrates/pocopine-core/src/animate/waapi.rs — WAAPI wrapper + AnimationHandlecrates/pocopine-core/src/animate/presets.rs — preset registry + atomscrates/pine-motion/src/spring.rs — spring physics + samplingcrates/pine-motion/src/easing.rs — named easings + linear-easing samplercrates/pine-motion/src/stagger.rs — stagger + origin modesdocs/animation.md (high-level guide), docs/animation-perf.md (RFC-039 §3 cache justification)examples/keep/src/components/auth_gate/KeepAuthGate.poco (preset usage), examples/hn/src/components/story_detail/StoryDetail.poco (six-phase attributes)