Skip to content

Commit aa8512f

Browse files
committed
chore: release v3.3.5
1 parent cb3bd83 commit aa8512f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/react-vant/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-vant",
3-
"version": "3.3.4",
3+
"version": "3.3.5",
44
"description": "React Mobile UI Components base on Vant UI",
55
"keywords": [
66
"ui",

packages/react-vant/src/components/picker/PickerColumn.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
} from 'react'
99
import clsx from 'clsx'
1010
import { PickerColumnOption, PickerColumnProps } from './PropsType'
11-
import { createNamespace, range } from '../utils'
11+
import { createNamespace, range, unitToPx } from '../utils'
1212
import { useIsomorphicLayoutEffect, useSetState, useTouch } from '../hooks'
1313
import ConfigProviderContext from '../config-provider/ConfigProviderContext'
1414

@@ -39,12 +39,14 @@ const PickerColumn = memo<
3939
const {
4040
valueKey,
4141
textKey,
42-
itemHeight,
42+
itemHeight: _itemHeight,
4343
visibleItemCount,
4444
placeholder,
4545
value,
4646
} = props
4747

48+
const itemHeight = useMemo(() => unitToPx(_itemHeight), [_itemHeight])
49+
4850
const options = useMemo(() => {
4951
if (Array.isArray(props.options) && !props.options.length) return []
5052
if (placeholder) {
@@ -96,7 +98,7 @@ const PickerColumn = memo<
9698

9799
const setIndex = (index: number) => {
98100
index = adjustIndex(index) || 0
99-
const offset = -index * props.itemHeight
101+
const offset = -index * itemHeight
100102
const trigger = () => {
101103
if (options[index]?.[valueKey] !== value) {
102104
onSelect(options[index])
@@ -114,7 +116,7 @@ const PickerColumn = memo<
114116

115117
const animate = (index: number) => {
116118
index = adjustIndex(index) || 0
117-
const offset = -index * props.itemHeight
119+
const offset = -index * itemHeight
118120
updateState({ offset })
119121
}
120122

@@ -143,7 +145,7 @@ const PickerColumn = memo<
143145
}
144146

145147
const getIndexByOffset = (offset: number) =>
146-
range(Math.round(-offset / props.itemHeight), 0, options.length - 1)
148+
range(Math.round(-offset / itemHeight), 0, options.length - 1)
147149

148150
const momentum = (distance: number, _duration: number) => {
149151
const speed = Math.abs(distance / _duration)
@@ -201,8 +203,8 @@ const PickerColumn = memo<
201203

202204
const offset = range(
203205
startOffset.current + touch.deltaY.current,
204-
-(options.length * props.itemHeight),
205-
props.itemHeight
206+
-(options.length * itemHeight),
207+
itemHeight
206208
)
207209

208210
updateState({

0 commit comments

Comments
 (0)