skyline-route
Original:🇨🇳 Chinese
Translated
Skyline custom route and page transition skills. It covers custom route animations (routeBuilder), preset routes (7 wx:// types), page back gestures, container transition animations (open-container), and Router API. It is suitable for implementing transition effects such as half-screen popups, page scaling, bottom pop-up, card expansion, etc. Trigger keywords: custom route, custom-route, routeBuilder, navigateTo, page transition, half screen, preset route, back gesture, open-container.
4installs
Added on
NPX Install
npx skill4agent add wechat-miniprogram/skyline-skills skyline-routeTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Skyline Custom Route and Page Transition
Applicable Scenarios
- Implement custom page transition animations (half-screen, scaling, fade-in, etc.)
- Quickly implement common transition effects using preset routes
- Configure page back gestures (horizontal/vertical/multi-directional)
- Implement container transition animation for card expansion to detail page
- Manage custom routes through Router API
Core Concepts
Route Capability Levels
| Level | Capability | Applicable Scenario |
|---|---|---|
| Preset Route | Use 7 built-in effects with one line of code | Quickly implement common transitions |
| Custom Route | Fully control animations via routeBuilder | Highly customized transitions |
| Container Transition | | Card expansion to detail page |
Animation Controller
| Property | Description |
|---|---|
| primaryAnimation | Page entry/exit animation progress (0→1 for entry, 1→0 for exit) |
| secondaryAnimation | Animation progress of current page when the next page enters (synchronized with the primaryAnimation of the next page) |
| userGestureInProgress | Whether the current routing progress is controlled by gesture |
| startUserGesture / stopUserGesture | Gesture takes over/releases routing control |
| didPop | Confirm to return to the previous page |
Document Index
Quickly locate according to requirements (paths are relative to ):
references/| I want to... | Refer to Document |
|---|---|
| Understand custom route principles and interfaces | |
| View half-screen/gesture back code patterns | |
| Quickly use preset routes | |
| Configure page back gestures | |
| Implement card expansion transition | |
| View Router API | |
| Understand navigateTo routing parameters | |
| Listen to routing events | |
Mandatory Rules
MUST (Must Comply)
-
Custom routes only take effect between consecutive Skyline pages: WebView pages do not support custom routesjs
// ✅ Page A (Skyline) → Page B (Skyline): Custom route takes effect // ❌ Page A (WebView) → Page B (Skyline): Degrade to default route -
The animation processing function must declare the 'worklet' directive:js
// ✅ Correct const handlePrimaryAnimation = () => { 'worklet' return { transform: `translateX(${...}px)` } } // ❌ Incorrect: Missing worklet directive, cannot execute in UI thread const handlePrimaryAnimation = () => { return { transform: `translateX(${...}px)` } } -
Gesture takeover must call startUserGesture / stopUserGesture in pairs:js
// ✅ Correct handleDragStart() { 'worklet' this.customRouteContext.startUserGesture() } handleDragEnd() { 'worklet' // ... In animation completion callback: stopUserGesture() } -
must call didPop when confirming return: The engine cannot automatically determine whether the developer wants to exit the pagejs
// ✅ Correct: Call didPop after animation is completed primaryAnimation.value = timing(0.0, { duration }, () => { 'worklet' didPop() stopUserGesture() }) -
The navigator component can only nest text nodes under Skyline:html
<!-- ✅ Correct --> <navigator url="/page">Click to jump</navigator> <!-- ❌ Incorrect: Cannot nest ordinary nodes such as view --> <navigator url="/page"><view>Jump</view></navigator>
NEVER (Prohibited Behaviors)
- NEVER directly modify in gesture processing without calling
primaryAnimation.valuestartUserGesture - NEVER assume that custom routes take effect on WebView pages (lower version basic libraries will degrade)
- NEVER access in non-worklet functions
primaryAnimation.value
Quick Reference
Preset Route Quick Check
| routeType | Effect | Minimum Basic Library Version |
|---|---|---|
| Bottom pop-up half screen | 3.1.0 |
| Full screen from bottom to top | 3.1.0 |
| Zoom in | 3.1.0 |
| iOS style modal | 3.1.0 |
| iOS modal embedded | 3.1.0 |
| Modal navigation | 3.1.0 |
| Modal popup | 3.1.0 |
js
// Use preset route
wx.navigateTo({
url: 'xxx',
routeType: 'wx://bottom-sheet',
routeOptions: { height: 60, round: true }
})API Quick Check
| API | Description | Minimum Basic Library Version |
|---|---|---|
| Register custom route | 2.29.2 |
| Remove custom route | 2.29.2 |
| Get routing context | 2.29.2 |
| Jump with specified route type | 2.29.2 |
| Override routing configuration | 3.4.0 |
| Pass routing parameters | 3.4.0 |
| Container transition jump | 3.12.2 |
| Listen before routing execution | 3.5.5 |
| Listen after routing execution | 3.5.5 |
Minimal Custom Route Example
js
// Register: Slide in from right
wx.router.addRouteBuilder('slide', ({ primaryAnimation }) => {
const { windowWidth } = wx.getWindowInfo()
const handlePrimaryAnimation = () => {
'worklet'
const transX = windowWidth * (1 - primaryAnimation.value)
return { transform: `translateX(${transX}px)` }
}
return { handlePrimaryAnimation }
})
// Jump
wx.navigateTo({ url: 'pageB', routeType: 'slide' })Scenario Decision Table
| Scenario | Recommended Solution |
|---|---|
| Bottom pop-up half screen | Preset route |
| iOS style modal | Preset route |
| Custom half screen + gesture | Custom route + handlePrimaryAnimation |
| Card expansion to detail page | |
| Page fade-in effect | Custom route + opacity animation |
| Require vertical back gesture | |
Related Skills
| Scenario | Recommended Skill | Description |
|---|---|---|
| Animation development | | Worklet animation system (timing/spring/Easing) |
| Gesture processing | | gesture-handler gesture component |
| Shared element | | share-element cross-page animation |
| Configuration explanation | | app.json/page.json configuration |
| Overview migration | | Skyline overview and migration guide |
References Directory Structure
references/
├── api/
│ ├── navigate-to.md
│ ├── route-events.md
│ └── router-api.md
├── custom-route/
│ ├── custom-route-guide.md
│ └── route-patterns.md
├── open-container/
│ └── open-container.md
├── pop-gesture/
│ └── pop-gesture.md
└── preset-route/
└── preset-route.md