Skip to content

Commit

Permalink
fix(picker-view): padding height
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshunnn committed Dec 23, 2024
1 parent 95ee3e5 commit 48b0ca7
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
nodeRef: scrollViewRef
})

// console.log('[mpx-picker-view-column], render ---> columnIndex=', columnIndex, 'initialIndex=', initialIndex, 'columnData=', columnData.length)
// console.log('[mpx-picker-view-column], render ---> columnIndex=', columnIndex, 'initialIndex=', initialIndex, 'columnData=', columnData.length, 'pickerH=', pickerH, 'itemRawH=', itemRawH, 'itemHeight=', itemHeight)

// const initialOffset = useMemo(() => ({
// x: 0,
// y: itemRawH * initialIndex
// }), [itemRawH])

const paddingHeight = useMemo(
() => Math.round((pickerH - itemHeight) / 2),
[pickerH, itemHeight]
)

const snapToOffsets = useMemo(
() => columnData.map((_, i) => i * itemRawH),
[columnData, itemRawH]
)

const paddingHeight = useMemo(
() => Math.round((pickerH - itemRawH) / 2),
[pickerH, itemRawH]
)

const contentContainerStyle = useMemo(() => {
return [{ paddingVertical: paddingHeight }]
}, [paddingHeight])
Expand Down Expand Up @@ -139,7 +139,7 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,

const onContentSizeChange = (_w: number, h: number) => {
const y = itemRawH * initialIndex
// console.log('[mpx-picker-view-column], onContentSizeChange --->', 'columnIndex=', columnIndex, '_w=', _w, 'h=', h, 'y=', y)
// console.log('[mpx-picker-view-column], onContentSizeChange --->', 'columnIndex=', columnIndex, '_w=', _w, 'h=', h, 'y=', y, 'itemRawH=', itemRawH)
if (y <= h) {
setTimeout(() => {
scrollViewRef.current?.scrollTo({ x: 0, y, animated: false })
Expand Down

0 comments on commit 48b0ca7

Please sign in to comment.