代码拉取完成,页面将自动刷新
模板版本:v0.2.2
@freakycoder/react-native-bounceable
[!TIP] Github 地址
进入到工程目录并输入以下命令:
npm i @freakycoder/react-native-bounceable@1.0.3
yarn add @freakycoder/react-native-bounceable@1.0.3
下面的代码展示了这个库的基本使用场景:
1、引入库文件
import RNBounceable from "@freakycoder/react-native-bounceable";
2、使用场景:
您可以将任何子组件放入 RNBounceable 组件中,当它被按下时,它会使其反弹
<RNBounceable onPress={() => {}}>
<View style={styles.bounceButtonStyle}>
<Text style={styles.bounceButtonTextStyle}>Bounce</Text>
</View>
</RNBounceable>
详细使用场景
import React from 'react';
import type { PropsWithChildren } from 'react';
import { StyleSheet, View, Text }from 'react-native';
import RNBounceable from "@freakycoder/react-native-bounceable";
let flag:boolean = true;
export function BounceableExample () {
const customStyle = {
backgroundColor: 'red',
padding: 10,
borderRadius: 100,
alignItems: 'center',
justifyContent: 'center',
};
<RNBounceable
style={[customStyle, styles.bounceStyle]}
onPress = {onPress}
bounceEffectIn={0.1}
bounceEffectOut={1.5}
bounceVelocityIn={60}
bounceVelocityOut={70}
bouncinessIn={50}
bouncinessOut={50}
>
<Text style={styles.textStyle}>Press Me</Text>
</RNBounceable>
}
const styles = StyleSheet.create({
container: {
width: '100%',
height: '100%',
},
bounceStyle: {
backgroundColor: 'lightblue'
},
textStyle: {
fontSize: 20,
color: 'red',
},
});
本文档内容基于以下版本验证:
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Property | Description | Type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
bounceEffectIn | change the bounce effect's value(reduce) | number | no | iOS/Android | yes |
bounceEffectOut | change the bounce effect's value(amplification) | number | no | iOS/Android | yes |
bounceVelocityIn | The speed of the press | number | no | iOS/Android | yes |
bounceVelocityOut | The speed at which it is released | number | no | iOS/Android | yes |
bouncinessIn | Elastic coefficient when pressed (set value 0-50 has obvious effect display) | number | no | iOS/Android | yes |
bouncinessOut | Elastic coefficient when released (set value 0-50 has obvious effect display) | number | no | iOS/Android | yes |
onPress | set your own logic for the onPress functionality | function | no | iOS/Android | yes |
style | set the style like any other View container | style | no | iOS/Android | yes |
本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。