|
1 | | -import Taro, { useState, useEffect } from '@tarojs/taro'; |
| 1 | +import Taro, { useState, useEffect, pxTransform } from '@tarojs/taro'; |
2 | 2 | import { View } from '@tarojs/components'; |
3 | 3 | import utils, { generateId } from '../utils/index'; |
4 | 4 | import { IProps } from '../../../@types/floatButton'; |
@@ -33,7 +33,7 @@ export default function ClFloatButton(props: IProps) { |
33 | 33 | closeWithShadow |
34 | 34 | } = props; |
35 | 35 | useEffect(() => { |
36 | | - const list = props.actionList || [] |
| 36 | + const list = actionList || [] |
37 | 37 | setActionListState(list.map((item: any) => { |
38 | 38 | item.cu_float_button_id = generateId() |
39 | 39 | return item |
@@ -97,6 +97,12 @@ export default function ClFloatButton(props: IProps) { |
97 | 97 | > |
98 | 98 | <View |
99 | 99 | className='float_button__fixed' |
| 100 | + style={{ |
| 101 | + top: props.position.top && props.position.top !== 'auto' ? pxTransform(props.position.top) : 'auto', |
| 102 | + right: props.position.right && props.position.right !== 'auto' ? pxTransform(props.position.right) : 'auto', |
| 103 | + bottom: props.position.bottom && props.position.bottom !== 'auto' ? pxTransform(props.position.bottom) : 'auto', |
| 104 | + left: props.position.left && props.position.left !== 'auto' ? pxTransform(props.position.left) : 'auto', |
| 105 | + }} |
100 | 106 | animation={animation} |
101 | 107 | onTouchStart={e => { |
102 | 108 | if (!move) return; |
@@ -163,9 +169,15 @@ ClFloatButton.defaultProps = { |
163 | 169 | direction: 'vertical', |
164 | 170 | onClick: () => { }, |
165 | 171 | shadow: true, |
166 | | - onActionClick: (index: number) => { }, |
| 172 | + onActionClick: () => { }, |
167 | 173 | actionList: [], |
168 | 174 | size: 'normal', |
169 | 175 | shape: 'round', |
170 | | - closeWithShadow: false |
| 176 | + closeWithShadow: false, |
| 177 | + position: { |
| 178 | + top: 'auto', |
| 179 | + right: 50, |
| 180 | + bottom: 200, |
| 181 | + left: 'auto' |
| 182 | + } |
171 | 183 | } as IProps; |
0 commit comments