Loading...
Loading...
Skill for Skyline Worklet Animation System. Use this skill when developing high-performance interactive animations with worklet functions, SharedValue, animation types (timing/spring/decay), Easing functions, combined animations, and thread communication (runOnUI/runOnJS). Suitable for animation scenarios that require direct UI thread response, such as dragging, gesture following, spring rebound, etc. Trigger keywords: worklet, worklet animation, SharedValue, shared variable, timing, spring, decay, Easing, runOnUI, runOnJS, applyAnimatedStyle, interactive animation, gesture animation, UI thread animation.
npx skill4agent add wechat-miniprogram/skyline-skills skyline-worklet| Concept | Description | Key API |
|---|---|---|
| worklet function | A function that can run on JS or UI thread, declared with the | |
| SharedValue | A variable synchronized across threads, read and write via | |
| Animation Driver | Bind SharedValue to node styles | |
const { shared, timing } = wx.worklet
// 1. Create SharedValue
const offset = shared(0)
// 2. Bind to node style (updater is a worklet function)
this.applyAnimatedStyle('#box', () => {
'worklet'
return { transform: `translateX(${offset.value}px)` }
})
// 3. Modify value to drive animation
offset.value = timing(300, { duration: 200 })references/| What I want to... | Refer to Document |
|---|---|
| Understand worklet architecture and complete concepts | |
| Use SharedValue and DerivedValue | |
| Operate scroll-view in worklet | |
| Use timing/spring/decay animations | |
| View Easing functions | |
| Use sequence/repeat/delay combined animations | |
| Understand runOnUI/runOnJS thread communication | |
'worklet'// ✅ Correct
function handleGesture(evt) {
'worklet'
offset.value += evt.deltaX
}
// ❌ Incorrect - Missing 'worklet' directive, cannot execute on UI thread
function handleGesture(evt) {
offset.value += evt.deltaX
}.value// ✅ Correct
const offset = shared(0)
offset.value = 100
// ❌ Incorrect - Direct assignment replaces the entire SharedValue object
const offset = shared(0)
offset = 100runOnJS// ✅ Correct
function showModal(msg) {
wx.showModal({ title: msg })
}
function handleTap() {
'worklet'
const fn = this.showModal.bind(this)
runOnJS(fn)('hello')
}
// ❌ Incorrect - Directly calling ordinary functions in worklet
function handleTap() {
'worklet'
this.showModal('hello')
}this.methodName.bind(this)// ✅ Correct
handleTap() {
'worklet'
const showModal = this.showModal.bind(this)
runOnJS(showModal)(msg)
}
// ❌ Incorrect - Missing bind(this), this pointer is lost
handleTap() {
'worklet'
runOnJS(this.showModal)(msg)
}"renderer": "skyline"wxrunOnJSthis.dataObject.freezethis.datasetData// ✅ Correct
handleTap() {
'worklet'
const msg = this.data.msg
}
// ❌ Incorrect - Destructuring will freeze the entire this.data
handleTap() {
'worklet'
const { msg } = this.data
}| Category | API | Description |
|---|---|---|
| Basic | | Create SharedValue |
| Basic | | Create derived value (analogous to computed) |
| Basic | | Cancel animation |
| Animation | | Time curve animation (300ms by default) |
| Animation | | Spring physics animation |
| Animation | | Scroll decay animation |
| Combine | | Execute sequentially |
| Combine | | Repeat (negative value = infinite) |
| Combine | | Execute with delay |
| Tool | | Execute on UI thread |
| Tool | | Callback to JS thread |
| Scenario | Recommended Solution |
|---|---|
| Smooth movement after click | |
| Rebound after gesture release | |
| Inertial sliding after gesture release | |
| Move first then bounce back | |
| Cyclic pulsation effect | |
| Start animation after delay | |
| Scenario | Recommended Skill | Description |
|---|---|---|
| Gesture components | | pan/tap/long-press gesture handling |
| Rendering engine overview | | Skyline configuration and migration |
| Style development | | WXSS support and differences |
| Route transition | | Custom route animations |
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