Last Updated on : 2024-06-05 03:14:35download
Motion component is used to enrich component actions.
Note: this component is added in the @2.0.0-rc.2 version.
Note: for more information, see Demo.
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
showFade: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.Fade"
textStyle={styles.text}
onPress={() => this.setState({ showFade: ! this.state.showFade })}
/>
<Motion.Fade
show={this.state.showFade}
onHide={() => this.setState({ showFade: false })}
>
<View style={styles.content} />
</Motion.Fade>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
},
content: {
width: winWidth,
height: 200,
backgroundColor: "#f0f"
}
});
export default MotionScene;
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
showPullUp: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.PullUp"
textStyle={styles.text}
onPress={() => this.setState({ showPullUp: ! this.state.showPullUp })}
/>
<Motion.PullUp
style={{ position: "absolute", bottom: 0 }}
dropHeight={200}
show={this.state.showPullUp}
onHide={() => this.setState({ showPullUp: false })}
>
<View style={[styles.content, { bottom: 0 }]} />
</Motion.PullUp>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
},
content: {
width: winWidth,
height: 200,
backgroundColor: "#f0f"
}
});
export default MotionScene;
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
showScaleFadeIn: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.ScaleFadeIn"
textStyle={styles.text}
onPress={() =>
this.setState({ showScaleFadeIn: ! this.state.showScaleFadeIn })
}
/>
<Motion.ScaleFadeIn
style={{ marginTop: 40 }}
show={this.state.showScaleFadeIn}
onHide={() => this.setState({ showScaleFadeIn: false })}
>
<View style={styles.content} />
</Motion.ScaleFadeIn>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
},
content: {
width: 200,
height: 200,
backgroundColor: "#f0f"
}
});
export default MotionScene;
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
showScalePullDown: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.ScalePullDown"
textStyle={styles.text}
onPress={() =>
this.setState({ showScalePullDown: ! this.state.showScalePullDown })
}
/>
<Motion.ScalePullDown
style={{ marginTop: 40 }}
show={this.state.showScalePullDown}
onHide={() => this.setState({ showScalePullDown: false })}
>
<View style={styles.content} />
</Motion.ScalePullDown>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
},
content: {
width: 200,
height: 200,
backgroundColor: "#f0f"
}
});
export default MotionScene;
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
showPushDown: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.PushDown"
textStyle={styles.text}
onPress={() =>
this.setState({ showPushDown: ! this.state.showPushDown })
}
/>
<Motion.PushDown
style={{ marginTop: 40 }}
show={this.state.showPushDown}
onHide={() => this.setState({ showPushDown: false })}
dropHeight={200}
>
<View style={styles.content} />
</Motion.PushDown>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
},
content: {
width: 200,
height: 40,
backgroundColor: "#f0f"
}
});
export default MotionScene;
import React from "react";
import { View, StyleSheet } from "react-native";
import { Button, Motion, Utils } from "tuya-panel-kit";
const { winWidth } = Utils.RatioUtils;
class MotionScene extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
show: false
};
}
render() {
return (
<View style={{ flex: 1 }}>
<Button
style={styles.button}
text="Motion.Toast"
textStyle={styles.text}
onPress={() => this.setState({ show: true })}
/>
<Motion.Toast
style={{ marginTop: 40 }}
show={this.state.show}
onFinish={() => this.setState({ show: false })}
>
<View style={{ width: 200, height: 200, backgroundColor: "#f0f" }} />
</Motion.Toast>
</View>
);
}
}
const styles = StyleSheet.create({
button: {
marginTop: 12,
width: winWidth,
height: 44,
backgroundColor: "#666"
},
text: {
color: "#fff"
}
});
export default MotionScene;
The style of the content.
Type | Required | Default value |
---|---|---|
ViewPropTypes.style | No | null |
Whether to display the content.
Type | Required | Default value |
---|---|---|
Bool | No | undefined |
Custom content.
Type | Required | Default value |
---|---|---|
Element | Yes | null |
Display duration of the animation.
Type | Required | Default value |
---|---|---|
Number | No | 300 |
Hiding duration of the animation.
Type | Required | Default value |
---|---|---|
Number | No | 300 |
Callback of showing the animation.
Type | Required | Default value |
---|---|---|
Func | No | () => {} |
Callback of hiding the animation.
Type | Required | Default value |
---|---|---|
Func | No | () => {} |
Animation effect configuration.
Type | Required | Default value |
---|---|---|
{ “duration”: “number”, “delay”: “number”, “isInteraction”: “Boolean”, “useNativeDriver”: “Boolean” } | No | { duration: 300, delay: 0, isInteraction: true, useNativeDriver: true, } |
Animation opacity.
Type | Required | Default value |
---|---|---|
Number | No | 1 |
Animation drop height.
Type | Required | Default value |
---|---|---|
Number | No | undefined |
The initial zoom scale.
Type | Required | Default value |
---|---|---|
Number | No | 0 |
The zoom scale at the end of the animation.
Type | Required | Default value |
---|---|---|
Number | No | 0 |
The initial zoom scale.
Type | Required | Default value |
---|---|---|
Number | No | 0 |
Animation drop height.
Type | Required | Default value |
---|---|---|
Number | No | 200 |
The initial zoom scale.
Type | Required | Default value |
---|---|---|
Number | No | 0 |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback