Skip to content

Commit

Permalink
fix: 解决小程序端卡顿问题 [#80]
Browse files Browse the repository at this point in the history
  • Loading branch information
zuolung committed Nov 30, 2021
1 parent f2066f4 commit 0bdf2c8
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions packages/vantui/src/picker-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
forwardRef,
memo,
} from 'react'
import { View } from '@tarojs/components'
import { View, CustomWrapper } from '@tarojs/components'
import * as utils from '../wxs/utils'
import { PickerColumnProps } from '../../types/picker-column'
import { range } from '../common/utils'
Expand Down Expand Up @@ -210,41 +210,43 @@ function Index(
])}
{...others}
>
<View
style={computed.wrapperStyle({
offset,
itemHeight,
visibleItemCount,
duration,
})}
onTouchStart={onTouchStart}
onTouchMove={onTouchMove}
onTouchEnd={onTouchEnd}
onTouchCancel={onTouchEnd}
catchMove
>
{options.map((option: any, index: number) => {
return (
<View
key={`picker-column__item${index}`}
data-index={index}
style={{ height: itemHeight + 'px' }}
className={
'van-ellipsis ' +
utils.bem('picker-column__item', {
disabled: option && option.disabled,
selected: index === currentIndex,
}) +
' ' +
(index === currentIndex ? 'active-class' : '')
}
onClick={onClickItem}
>
{computed.optionText(option, valueKey)}
</View>
)
})}
</View>
<CustomWrapper>
<View
style={computed.wrapperStyle({
offset,
itemHeight,
visibleItemCount,
duration,
})}
onTouchStart={onTouchStart}
onTouchMove={onTouchMove}
onTouchEnd={onTouchEnd}
onTouchCancel={onTouchEnd}
catchMove
>
{options.map((option: any, index: number) => {
return (
<View
key={`picker-column__item${index}`}
data-index={index}
style={{ height: itemHeight + 'px' }}
className={
'van-ellipsis ' +
utils.bem('picker-column__item', {
disabled: option && option.disabled,
selected: index === currentIndex,
}) +
' ' +
(index === currentIndex ? 'active-class' : '')
}
onClick={onClickItem}
>
{computed.optionText(option, valueKey)}
</View>
)
})}
</View>
</CustomWrapper>
</View>
)
}
Expand Down

0 comments on commit 0bdf2c8

Please sign in to comment.