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-route

Tags

Translated version includes tags in frontmatter

SKILL.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

LevelCapabilityApplicable Scenario
Preset RouteUse 7 built-in effects with one line of codeQuickly implement common transitions
Custom RouteFully control animations via routeBuilderHighly customized transitions
Container Transition
<open-container>
element-level transition
Card expansion to detail page

Animation Controller

PropertyDescription
primaryAnimationPage entry/exit animation progress (0→1 for entry, 1→0 for exit)
secondaryAnimationAnimation progress of current page when the next page enters (synchronized with the primaryAnimation of the next page)
userGestureInProgressWhether the current routing progress is controlled by gesture
startUserGesture / stopUserGestureGesture takes over/releases routing control
didPopConfirm 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
custom-route/custom-route-guide.md
View half-screen/gesture back code patterns
custom-route/route-patterns.md
Quickly use preset routes
preset-route/preset-route.md
Configure page back gestures
pop-gesture/pop-gesture.md
Implement card expansion transition
open-container/open-container.md
View Router API
api/router-api.md
Understand navigateTo routing parameters
api/navigate-to.md
Listen to routing events
api/route-events.md

Mandatory Rules

MUST (Must Comply)

  1. Custom routes only take effect between consecutive Skyline pages: WebView pages do not support custom routes
    js
    // ✅ Page A (Skyline) → Page B (Skyline): Custom route takes effect
    // ❌ Page A (WebView) → Page B (Skyline): Degrade to default route
  2. 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)` }
    }
  3. Gesture takeover must call startUserGesture / stopUserGesture in pairs:
    js
    // ✅ Correct
    handleDragStart() {
      'worklet'
      this.customRouteContext.startUserGesture()
    }
    handleDragEnd() {
      'worklet'
      // ... In animation completion callback:
      stopUserGesture()
    }
  4. must call didPop when confirming return: The engine cannot automatically determine whether the developer wants to exit the page
    js
    // ✅ Correct: Call didPop after animation is completed
    primaryAnimation.value = timing(0.0, { duration }, () => {
      'worklet'
      didPop()
      stopUserGesture()
    })
  5. 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)

  1. NEVER directly modify
    primaryAnimation.value
    in gesture processing without calling
    startUserGesture
  2. NEVER assume that custom routes take effect on WebView pages (lower version basic libraries will degrade)
  3. NEVER access
    primaryAnimation.value
    in non-worklet functions

Quick Reference

Preset Route Quick Check

routeTypeEffectMinimum Basic Library Version
wx://bottom-sheet
Bottom pop-up half screen3.1.0
wx://upwards
Full screen from bottom to top3.1.0
wx://zoom
Zoom in3.1.0
wx://cupertino-modal
iOS style modal3.1.0
wx://cupertino-modal-inside
iOS modal embedded3.1.0
wx://modal-navigation
Modal navigation3.1.0
wx://modal
Modal popup3.1.0
js
// Use preset route
wx.navigateTo({
  url: 'xxx',
  routeType: 'wx://bottom-sheet',
  routeOptions: { height: 60, round: true }
})

API Quick Check

APIDescriptionMinimum Basic Library Version
wx.router.addRouteBuilder(type, builder)
Register custom route2.29.2
wx.router.removeRouteBuilder(type)
Remove custom route2.29.2
wx.router.getRouteContext(this)
Get routing context2.29.2
wx.navigateTo({ routeType })
Jump with specified route type2.29.2
wx.navigateTo({ routeConfig })
Override routing configuration3.4.0
wx.navigateTo({ routeOptions })
Pass routing parameters3.4.0
wx.navigateTo({ withOpenContainer })
Container transition jump3.12.2
wx.onBeforeAppRoute(fn)
Listen before routing execution3.5.5
wx.onAppRoute(fn)
Listen after routing execution3.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

ScenarioRecommended Solution
Bottom pop-up half screenPreset route
wx://bottom-sheet
iOS style modalPreset route
wx://cupertino-modal
Custom half screen + gestureCustom route + handlePrimaryAnimation
Card expansion to detail page
<open-container>
container transition
Page fade-in effectCustom route + opacity animation
Require vertical back gesture
popGestureDirection: 'vertical'

Related Skills

ScenarioRecommended SkillDescription
Animation development
skyline-worklet
Worklet animation system (timing/spring/Easing)
Gesture processing
skyline-components
gesture-handler gesture component
Shared element
skyline-components
share-element cross-page animation
Configuration explanation
skyline-config
app.json/page.json configuration
Overview migration
skyline-overview
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