share-element

View Markdown

Base Library 2.16.0 or later is required. For earlier versions, see compatibility handling.

WeChat for Windows: Supported

WeChat for Mac: Supported

WeChat for HarmonyOS: Supported

Rendering framework support: Skyline (debug using the latest Nightly tools), WebView

Feature Description

Shared Element.

A shared element is a type of animation, similar to the flutter Hero animation, where elements appear to travel between pages. This component must be used in conjunction with the page-container component.

To use this feature, place the share-element component on the current page and the corresponding share-element component within the page-container container. The mapping between them is established via the attribute value key. When page-container is set to display, shared elements with the transform attribute set to true will trigger an animation. A return animation is generated when the current page container is exited.

  1. Using the worklet function requires enabling the "Compile JS to ES5" or "Compile worklet functions" option in the Developer Tools.

General Attributes

Attribute Type Default Value Required Description Minimum Version
key string Yes Mapping identifier, unique within the page 2.29.2
transform boolean false No Whether to enable animation 2.16.0
duration number 300 No Animation duration, in milliseconds 2.16.0
easing-function string ease-out No `css`Easing function 2.16.0

Skyline-Specific Attributes

Property Type Default Value Required Description Minimum Version
transition-on-gesture boolean false No Whether to perform animation during gesture-based navigation back 2.29.2
shuttle-on-push string to No Specifies the flying object in the push phase 2.30.2
Valid Values Description
from Uses the source page node as the flying object in the push phase
to Uses the target page node as the flying object in the push phase
from Uses the source page node as the flying object in the pop phase
to Uses the target page node as the flying object in the pop phase
shuttle-on-pop string to No Specifies the flying object in the pop phase 2.30.2
worklet:onframe callback No Animation frame callback 2.30.2
rect-tween-type string materialRectArc No Animation interpolation curve 2.30.2
Valid Values Description
materialRectArc Rectangular diagonal animation
materialRectCenterArc Radial animation
linear
elasticIn
elasticOut
elasticInOut
bounceIn
bounceOut
bounceInOut
cubic-bezier(x1, y1, x2, y2 )

WebView Sample Code

Preview in DevTools

Skyline Sample Code

Preview in DevTools