MCPInstall

skyline-worklet

Skyline Worklet 动画系统技能。使用 worklet 函数、共享变量(SharedValue)、动画类型(timing/spring/decay)、Easing 缓动函数、组合动画和线程通信(runOnUI/runOnJS)开发高性能交互动画时使用此技能。适用于拖拽、手势跟随、弹簧回弹等需要 UI 线程直接响应的动画场景。触发关键词:worklet、worklet 动画、SharedValue、共享变量、timing、spring、decay、Easing、runOnUI、runOnJS、applyAnimatedStyle、交互动画、手势动画、UI 线程动画。

Installs
1K
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/wechat-miniprogram/skyline-skills --skill skyline-worklet
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads skyline-worklet automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Worklet 动画系统

适用场景

  • 实现手势跟随、拖拽等交互动画
  • 使用 timing/spring/decay 创建动画效果
  • 通过 SharedValue 驱动节点样式变化
  • 组合多段动画(序列、重复、延迟)
  • 在 UI 线程和 JS 线程间传递数据

核心概念

双线程架构与 Worklet 的意义

小程序双线程架构中,UI 事件需跨线程传递到 JS 线程再回传,交互动画会有明显延迟。Worklet 动画让动画逻辑直接运行在 UI 线程,实现类原生动画体验。

三大核心概念

概念说明关键 API
worklet 函数可运行在 JS 或 UI 线程的函数,顶部声明 'worklet' 指令runOnUI(), runOnJS()
共享变量跨线程同步的变量,通过 .value 读写shared(), derived()
动画驱动将 SharedValue 绑定到节点样式applyAnimatedStyle()

基本流程

const { shared, timing } = wx.worklet

// 1. 创建共享变量
const offset = shared(0)

// 2. 绑定到节点样式(updater 为 worklet 函数)
this.applyAnimatedStyle('#box', () => {
  'worklet'
  return { transform: `translateX(${offset.value}px)` }
})

// 3. 修改值驱动动画
offset.value = timing(300, { duration: 200 })

文档索引

根据需求快速定位(路径相对于 references/):

我想要...查阅文档
了解 worklet 架构和完整概念core/worklet-overview.md
使用 SharedValue 和 DerivedValuebase/shared-derived.md
在 worklet 中操作 scroll-viewbase/scroll-view-context.md
使用 timing/spring/decay 动画animation/timing-spring-decay.md
查看 Easing 缓动函数animation/easing.md
使用序列/重复/延迟组合动画animation/combine-animation.md
了解 runOnUI/runOnJS 线程通信tool/thread-communication.md

强制规则

MUST: worklet 函数必须声明 'worklet' 指令

// ✅ Correct
function handleGesture(evt) {
  'worklet'
  offset.value += evt.deltaX
}

// ❌ Incorrect - 缺少 'worklet' 指令,无法在 UI 线程执行
function handleGesture(evt) {
  offset.value += evt.deltaX
}

MUST: SharedValue 必须通过 .value 读写

// ✅ Correct
const offset = shared(0)
offset.value = 100

// ❌ Incorrect - 直接赋值会替换整个 SharedValue 对象
const offset = shared(0)
offset = 100

MUST: 访问非 worklet 函数必须使用 runOnJS

// ✅ Correct
function showModal(msg) {
  wx.showModal({ title: msg })
}
function handleTap() {
  'worklet'
  const fn = this.showModal.bind(this)
  runOnJS(fn)('hello')
}

// ❌ Incorrect - worklet 中直接调用普通函数
function handleTap() {
  'worklet'
  this.showModal('hello')
}

MUST: 页面方法必须通过 this.methodName.bind(this) 访问

// ✅ Correct
handleTap() {
  'worklet'
  const showModal = this.showModal.bind(this)
  runOnJS(showModal)(msg)
}

// ❌ Incorrect - 未 bind(this),this 指向丢失
handleTap() {
  'worklet'
  runOnJS(this.showModal)(msg)
}

MUST: Worklet 动画仅在 Skyline 渲染模式下可用

  • 确保 app.json 配置 "renderer": "skyline"
  • 确保开发者工具勾选「将 JS 编译成 ES5」

NEVER: 在 worklet 函数中直接调用 wx API

必须通过 runOnJS 回到 JS 线程。

NEVER: 通过解构 this.data 访问属性

会导致 Object.freeze 冻结 this.data,setData 将失效。

// ✅ Correct
handleTap() {
  'worklet'
  const msg = this.data.msg
}

// ❌ Incorrect - 解构会冻结整个 this.data
handleTap() {
  'worklet'
  const { msg } = this.data
}

Quick Reference

API 速查表

分类API说明
基础shared(initialValue)创建 SharedValue
基础derived(updaterWorklet)创建衍生值(类比 computed)
基础cancelAnimation(sharedValue)取消动画
动画timing(toValue, options?, callback?)时间曲线动画(默认 300ms)
动画spring(toValue, options?, callback?)弹簧物理动画
动画decay(options?, callback?)滚动衰减动画
组合sequence(anim1, anim2, ...)依次执行
组合repeat(anim, reps, reverse?, callback?)重复(负值=无限)
组合delay(ms, anim)延迟执行
工具runOnUI(workletFn)在 UI 线程执行
工具runOnJS(normalFn)回调 JS 线程

场景 → 方案映射

场景推荐方案
点击后平滑移动timing + Easing
手势松开回弹spring
手势松开惯性滑动decay + velocity
先移动再弹回sequence(timing, spring)
循环脉动效果repeat(timing, -1, true)
延迟后开始动画delay(ms, timing/spring)

相关技能

场景推荐技能说明
手势组件skyline-componentspan/tap/long-press 手势处理
渲染引擎概览skyline-overviewSkyline 配置和迁移
样式开发skyline-wxssWXSS 支持与差异
路由转场skyline-route自定义路由动画

References 目录结构

references/
├── animation/
│   ├── combine-animation.md
│   ├── easing.md
│   └── timing-spring-decay.md
├── base/
│   ├── scroll-view-context.md
│   └── shared-derived.md
├── core/
│   └── worklet-overview.md
└── tool/
    └── thread-communication.md

FAQ

What does the skyline-worklet skill do?

Skyline Worklet 动画系统技能。使用 worklet 函数、共享变量(SharedValue)、动画类型(timing/spring/decay)、Easing 缓动函数、组合动画和线程通信(runOnUI/runOnJS)开发高性能交互动画时使用此技能。适用于拖拽、手势跟随、弹簧回弹等需要 UI 线程直接响应的动画场景。触发关键词:worklet、worklet 动画、SharedValue、共享变量、timing、spring、decay、Easing、runOnUI、runOnJS、applyAnimatedStyle、交互动画、手势动画、UI 线程动画。

How do I install skyline-worklet?

Run npx skills add https://github.com/wechat-miniprogram/skyline-skills --skill skyline-worklet in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/skyline-worklet/ (personal) or .claude/skills/skyline-worklet/ (project).

Which AI agents can use skyline-worklet?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is skyline-worklet safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains skyline-worklet?

It is published by wechat-miniprogram in wechat-miniprogram/skyline-skills. It has 1,042 recorded installs.

More from wechat-miniprogram/skyline-skills

View all →

skyline-components

wechat-miniprogram/skyline-skills

Skyline 组件开发技能。涵盖 scroll-view 及其增强模式(列表/嵌套滚动)、swiper 高级特性、表单组件、图片/文本组件、半屏可拖拽组件、共享元素动画等。适用于需要开发滚动列表、轮播、表单输入、页面过渡动画等场景。

1.1K installs

skyline-overview

wechat-miniprogram/skyline-skills

Skyline 渲染引擎概览与迁移技能。了解 Skyline 架构、性能优势、功能特性、迁移指南和最佳实践时使用此技能。适用于初次接触 Skyline、评估迁移成本、或需要了解整体框架的场景。

1.1K installs

skyline-route

wechat-miniprogram/skyline-skills

Skyline 自定义路由与页面转场技能。涵盖自定义路由动画(routeBuilder)、预设路由(7 种 wx:// 类型)、页面返回手势、容器转场动画(open-container)、Router API。适用于实现半屏弹窗、页面缩放、底部弹出、卡片展开等转场效果。触发关键词:自定义路由、custom-route、routeBuilder、navigateTo、页面转场、半屏、预设路由、返回手势、open-container。

Backend & APIs996 installs

skyline-config

wechat-miniprogram/skyline-skills

Skyline 小程序 JSON 配置规范技能。涵盖 app.json 全局配置(renderer、rendererOptions、componentFramework)、页面 json 配置(navigationStyle、disableScroll)、project.config.json 项目配置。适用于创建新 Skyline 项目、迁移 WebView 项目、配置混合渲染。触发关键词:app.json、页面配置、renderer、rendererOptions、skyline配置、navigationStyle、disableScroll、componentFramework、glass-easel、project.config.json。

976 installs

skyline-wxss

wechat-miniprogram/skyline-skills

Skyline WXSS 样式支持技能。提供 Skyline 支持的 CSS 属性、值和限制信息。触发关键词:WXSS、CSS 支持、样式兼容性、属性支持、不支持的属性、display grid、position sticky、overflow、filter、渐变、gradient、linear-gradient、radial-gradient、conic-gradient、border-style、white-space、font-weight、text-decoration、text-overflow、aspect-ratio、will-change、calc、env、mask、mask-image、background-image、transition、animation、transform、font-feature-settings。

Frontend & Design954 installs

skyline-scroll-api

wechat-miniprogram/skyline-skills

Skyline 滚动控制 API 技能。涵盖 ScrollViewContext(程序化下拉刷新、下拉二级、滚动定位)、DraggableSheetContext(半屏面板程序化滚动)、worklet.scrollViewContext(UI 线程直接控制滚动)。适用于程序化触发刷新/二级、控制 DraggableSheet 位置、在 worklet 中操作滚动。触发关键词:ScrollViewContext、DraggableSheetContext、scrollTo、triggerRefresh、triggerTwoLevel、下拉刷新API、下拉二级API、滚动API、worklet scrollViewContext。

Backend & APIs916 installs

Popular frontend & design skills

View category →

setup-matt-pocock-skills

mattpocock/skills

Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.

Frontend & Design1.1M installs

frontend-design

anthropics/skills

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

OfficialFrontend & Design1M installs

hyperframes-animation

heygen-com/hyperframes

All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.

prototype

mattpocock/skills

Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

Frontend & Design999.2K installs

hyperframes-core

heygen-com/hyperframes

The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.

Frontend & Design930.5K installs

vercel-react-best-practices

vercel-labs/agent-skills

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

OfficialFrontend & Design843.1K installs