Skip to content

Commit

Permalink
chore: release v3.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
3lang3 committed May 15, 2024
1 parent cb3bd83 commit aa8512f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/react-vant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-vant",
"version": "3.3.4",
"version": "3.3.5",
"description": "React Mobile UI Components base on Vant UI",
"keywords": [
"ui",
Expand Down
16 changes: 9 additions & 7 deletions packages/react-vant/src/components/picker/PickerColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
} from 'react'
import clsx from 'clsx'
import { PickerColumnOption, PickerColumnProps } from './PropsType'
import { createNamespace, range } from '../utils'
import { createNamespace, range, unitToPx } from '../utils'
import { useIsomorphicLayoutEffect, useSetState, useTouch } from '../hooks'
import ConfigProviderContext from '../config-provider/ConfigProviderContext'

Expand Down Expand Up @@ -39,12 +39,14 @@ const PickerColumn = memo<
const {
valueKey,
textKey,
itemHeight,
itemHeight: _itemHeight,
visibleItemCount,
placeholder,
value,
} = props

const itemHeight = useMemo(() => unitToPx(_itemHeight), [_itemHeight])

const options = useMemo(() => {
if (Array.isArray(props.options) && !props.options.length) return []
if (placeholder) {
Expand Down Expand Up @@ -96,7 +98,7 @@ const PickerColumn = memo<

const setIndex = (index: number) => {
index = adjustIndex(index) || 0
const offset = -index * props.itemHeight
const offset = -index * itemHeight
const trigger = () => {
if (options[index]?.[valueKey] !== value) {
onSelect(options[index])
Expand All @@ -114,7 +116,7 @@ const PickerColumn = memo<

const animate = (index: number) => {
index = adjustIndex(index) || 0
const offset = -index * props.itemHeight
const offset = -index * itemHeight
updateState({ offset })
}

Expand Down Expand Up @@ -143,7 +145,7 @@ const PickerColumn = memo<
}

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

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

const offset = range(
startOffset.current + touch.deltaY.current,
-(options.length * props.itemHeight),
props.itemHeight
-(options.length * itemHeight),
itemHeight
)

updateState({
Expand Down

0 comments on commit aa8512f

Please sign in to comment.