Skip to content

Commit 16ee064

Browse files
authored
feat(v15): swipe 增加 v15 的 demo (#3160)
1 parent 794a53f commit 16ee064

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

src/packages/swipe/demos/h5/demo2.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const ViewNode = (text: string, style: any) => {
77
<div
88
style={{
99
display: 'flex',
10-
width: 60,
11-
height: 104,
10+
width: 56,
11+
height: 96,
1212
flexDirection: 'column',
1313
justifyContent: 'center',
1414
alignItems: 'center',
@@ -25,32 +25,34 @@ const App = () => {
2525
return (
2626
<>
2727
<Swipe
28-
style={{ height: 104 }}
28+
style={{ height: 96 }}
2929
rightAction={
3030
<div
3131
style={{
3232
display: 'flex',
3333
flexDirection: 'row',
34-
width: 240,
35-
height: 104,
34+
width: 224,
35+
height: 96,
3636
fontSize: 12,
37+
borderRadius: 8,
38+
overflow: 'hidden',
3739
}}
3840
>
3941
<>
40-
{ViewNode('设置常买', {
41-
background: '#F8F8F8',
42-
color: '#1A1A1A',
42+
{ViewNode('加常买', {
43+
background: '#fff4e8',
44+
color: '#b5691a',
4345
})}
44-
{ViewNode('移入收藏', {
45-
background: '#ffcc00',
46+
{ViewNode('收藏', {
47+
background: '#ffbf00',
4648
color: '#FFF',
4749
})}
4850
{ViewNode('看相似', {
49-
background: '#FF860D',
51+
background: '#ff791a',
5052
color: '#FFF',
5153
})}
5254
{ViewNode('删除', {
53-
background: '#FA2C19',
55+
background: '#ff0f23',
5456
color: '#FFF',
5557
})}
5658
</>

src/packages/swipe/demos/taro/demo2.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const ViewNode = (text: string, style: any) => {
1010
<View
1111
style={{
1212
display: 'flex',
13-
width: pxTransform(60),
14-
height: pxTransform(104),
13+
width: pxTransform(56),
14+
height: pxTransform(96),
1515
flexDirection: 'column',
1616
justifyContent: 'center',
1717
alignItems: 'center',
@@ -30,32 +30,34 @@ const App = () => {
3030
return (
3131
<>
3232
<Swipe
33-
style={{ height: pxTransform(104) }}
33+
style={{ height: pxTransform(96) }}
3434
rightAction={
3535
<View
3636
style={{
3737
display: 'flex',
3838
flexDirection: 'row',
39-
width: pxTransform(240),
40-
height: pxTransform(104),
39+
width: pxTransform(224),
40+
height: pxTransform(96),
4141
fontSize: pxTransform(12),
42+
borderRadius: pxTransform(8),
43+
overflow: 'hidden',
4244
}}
4345
>
4446
<>
45-
{ViewNode('设置常买', {
46-
backgroundColor: '#F8F8F8',
47-
color: '#1A1A1A',
47+
{ViewNode('加常买', {
48+
background: '#fff4e8',
49+
color: '#b5691a',
4850
})}
49-
{ViewNode('移入收藏', {
50-
backgroundColor: '#ffcc00',
51+
{ViewNode('收藏', {
52+
background: '#ffbf00',
5153
color: '#FFF',
5254
})}
5355
{ViewNode('看相似', {
54-
backgroundColor: '#FF860D',
56+
background: '#ff791a',
5557
color: '#FFF',
5658
})}
5759
{ViewNode('删除', {
58-
backgroundColor: '#FA2C19',
60+
background: '#ff0f23',
5961
color: '#FFF',
6062
})}
6163
</>

src/packages/swipe/swipe.taro.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, {
99
import classNames from 'classnames'
1010
import { ITouchEvent, View } from '@tarojs/components'
1111
import { BaseEventOrig } from '@tarojs/components/types/common'
12-
import { useReady } from '@tarojs/taro'
12+
import { nextTick, useReady } from '@tarojs/taro'
1313
import { useTouch } from '@/hooks/use-touch'
1414
import { getRectByTaro } from '@/utils/get-rect-by-taro'
1515
import { ComponentDefaults } from '@/utils/typings'
@@ -58,7 +58,7 @@ export const Swipe = forwardRef<
5858
setActionWidth((v: any) => ({ ...v, right: rightRect.width }))
5959
}
6060
}
61-
setTimeout(() => getWidth())
61+
nextTick(() => getWidth())
6262
})
6363

6464
const { children, className, style } = { ...defaultProps, ...props }

0 commit comments

Comments
 (0)