@@ -4,7 +4,7 @@ Achieve timing animation, use `bindingx` first when the environment is allowed b
44
55## Supported
66
7- <img alt =" browser " src =" https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" weex " src =" https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" miniApp " src =" https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" bytedanceMicroApp " src =" https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width =" 25px " height =" 25px " >
7+ <img alt =" browser " src =" https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" weex " src =" https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" miniApp " src =" https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src =" https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa -200-200.svg" width =" 25px " height =" 25px " >
88
99## Install
1010
@@ -37,33 +37,30 @@ animate({
3737
3838### ` animate(config, callback) `
3939
40- #### Supported
41- <img alt =" browser " src =" https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" weex " src =" https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" miniApp " src =" https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width =" 25px " height =" 25px " />
42-
4340#### Arguments
4441
4542| Property | Type | Description | Required | Default | Supported |
4643| --- | --- | --- | --- | --- | --- |
47- | config.props | ` array ` | See below for details | yes | - | |
48- | callback | ` function ` | Triggered after the animation is complete | no | - | <img alt =" browser " src =" https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" weex " src =" https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width =" 25px " height =" 25px " /> |
44+ | config.props | ` Array ` | See below for details | yes | - | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
45+ | callback | ` function ` | Triggered after the animation is complete | no | - | <img alt =" browser " src =" https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width =" 25px " height =" 25px " /> <img alt =" weex " src =" https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width =" 25px " height =" 25px " /> |
4946
5047config.props array member content:
5148
5249| Property | Type | Description | Required | Default | Supported |
5350| --- | --- | --- | --- | --- | --- |
54- | element | `DOMNode| string` | DOM element, The mimi app environment is a ` string ` type identifier, see details` export() ` | yes | - | |
55- | property | ` string ` | Animation property, see details [ bindingx properties support] ( https://alibaba.github.io/bindingx/guide/cn_api_attributes ) | yes | - | |
56- | start | ` value ` | start value | no | - | |
57- | end | ` value ` | end value | yes | - | |
58- | duration | ` number ` | Animation duration | no | 0 | |
59- | delay | ` number ` | Animation delay time | 否 | 0 | |
60- | easing | ` string ` | Animation effect,see details [ bindingx easing support] ( https://alibaba.github.io/bindingx/guide/cn_api_interpolator ) | 否 | ` easeOutSine ` | |
51+ | element | `DOMNode| string` | DOM element, The mimi app environment is a ` string ` type identifier, see details` export() ` | yes | - | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
52+ | property | ` string ` | Animation property, see details [ bindingx properties support] ( https://alibaba.github.io/bindingx/guide/cn_api_attributes ) | yes | - | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
53+ | start | ` value ` | start value | no | - | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
54+ | end | ` value ` | end value | yes | - | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
55+ | duration | ` number ` | Animation duration | no | 0 | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
56+ | delay | ` number ` | Animation delay time | 否 | 0 | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
57+ | easing | ` string ` | Animation effect,see details [ bindingx easing support] ( https://alibaba.github.io/bindingx/guide/cn_api_interpolator ) | 否 | ` easeOutSine ` | < img alt = " browser " src = " https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " weex " src = " https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " miniApp " src = " https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width = " 25px " height = " 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " > |
6158
6259### ` export() `
6360
6461#### Supported
6562
66- <img alt =" miniApp " src =" https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width =" 25px " height =" 25px " />
63+ <img alt =" miniApp " src =" https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg " width =" 25px " height =" 25px " /> < img alt = " wechatMiniprogram " src = " https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " bytedanceMicroApp " src = " https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg " width = " 25px " height = " 25px " > < img alt = " quickApp " src = " https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg " width = " 25px " height = " 25px " >
6764
6865Because the mini app can't provide ` DOMNode ` , and the animation application is different. So the mini app uses this method to get the animation content and then manually bind to the element.
6966
7572
7673| Property | Type | Description |
7774| --- | --- | --- |
78- | result | ` object ` | return object |
79- | result[ key] | ` array ` | ` key ` is config.props[ n] .element,` value ` is the mini app animation content, bind the value to the element |
75+ | result | ` Object ` | return object |
76+ | result[ key] | ` Array ` | ` key ` is config.props[ n] .element,` value ` is the mini app animation content, bind the value to the element |
8077
8178#### Usage
8279
83- ``` html
84- <view animation =" {{animationInfo1}}" style =" background :red ;height :100 rpx;width :100 rpx" ></view >
85- <view animation =" {{animationInfo2}}" style =" background :yellow ;height :100 rpx;width :100 rpx" ></view >
86- ```
87-
88- ``` javascript
89- const animationResult = animation ({
90- props: [{
91- element: ' view1' ,
92- property: ' transform.translateX' ,
93- easing: ' easeOutSine' ,
94- duration: 200 ,
95- start: 0 ,
96- end: 200 ,
97- delay: 100
98- }, {
99- element: ` view2` ,
100- property: ' opacity' ,
101- easing: ' easeOutSine' ,
102- duration: 200 ,
103- end: 0.2 ,
104- delay: 100
105- }]
106- }).export ()
107-
108- setTimeout (() => {
109- this .setData ({
110- animationInfo1: animationResult .view1 ,
111- animationInfo2: animationResult .view2 ,
112- });
113- }, 500 );
80+ ``` jsx
81+ import { createElement , useState , useEffect , useRef , Fragment } from ' rax' ;
82+ import animate from ' universal-animation' ;
83+ import findDOMNode from ' rax-find-dom-node' ;
84+ import View from ' rax-view' ;
85+ import { isMiniApp } from ' universal-env' ;
86+
87+ export default function Demo () {
88+ const [animationInfo1 , setAnimationInfo1 ] = useState ({});
89+ const [animationInfo2 , setAnimationInfo2 ] = useState ({});
90+ const block1 = useRef ();
91+ const block2 = useRef ();
92+
93+ useEffect (() => {
94+ const animationResult = animate (
95+ {
96+ props: [
97+ {
98+ element: isMiniApp ? ' view1' : findDOMNode (block1 .current ),
99+ property: ' transform.translateX' ,
100+ easing: ' easeOutSine' ,
101+ duration: 200 ,
102+ start: 0 ,
103+ end: 200 ,
104+ delay: 100 ,
105+ },
106+ {
107+ element: isMiniApp ? ' view2' : findDOMNode (block2 .current ),
108+ property: ' opacity' ,
109+ easing: ' easeOutSine' ,
110+ duration: 200 ,
111+ end: 0.2 ,
112+ delay: 100 ,
113+ },
114+ ],
115+ },
116+ () => {
117+ console .log (' timing end' );
118+ },
119+ ).export ();
120+
121+ if (isMiniApp) {
122+ setAnimationInfo1 (animationResult .view1 );
123+ setAnimationInfo2 (animationResult .view2 );
124+ }
125+ }, []);
126+
127+ return (
128+ <>
129+ < View
130+ ref= {block1}
131+ animation= {animationInfo1}
132+ style= {{ backgroundColor: ' red' , height: ' 100rpx' , width: ' 100rpx' }}
133+ >< / View>
134+ < View
135+ ref= {block2}
136+ animation= {animationInfo2}
137+ style= {{ backgroundColor: ' yellow' , height: ' 100rpx' , width: ' 100rpx' }}
138+ >< / View>
139+ < / >
140+ );
141+ }
114142```
115143
116144
117145
118-
0 commit comments