Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
fix(virtual-scroll): removed viewport prop & fixed computed viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Nov 3, 2020
1 parent a1db9b4 commit d76edcd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
12 changes: 2 additions & 10 deletions src/components/virtual-scroll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ const AtVirtualScroll = defineComponent({
type: [Number, String] as PropType<AtVirtualScrollProps['bench']>,
default: 0,
},
viewport: {
type: [Number, String] as PropType<AtVirtualScrollProps['viewport']>,
default: 5,
},
itemHeight: {
type: [Number, String] as PropType<AtVirtualScrollProps['itemHeight']>,
required: true,
Expand Down Expand Up @@ -71,10 +67,6 @@ const AtVirtualScroll = defineComponent({
return parseInt(`${props.bench}`, 10)
})

const __viewport = computed<number>(() => {
return parseInt(`${props.viewport}`, 10) - 1
})

const __itemHeight = computed<number>(() => {
return parseInt(`${props.itemHeight}`, 10)
})
Expand All @@ -84,7 +76,7 @@ const AtVirtualScroll = defineComponent({
})

const lastToRender = computed<number>(() => {
return Math.min(props.items.length, last.value + __viewport.value + __bench.value)
return Math.min(props.items.length, last.value + __bench.value)
})

const { dimensions } = useDimensions(props)
Expand Down Expand Up @@ -136,7 +128,7 @@ const AtVirtualScroll = defineComponent({
}

function getLast(first: number): number {
const height = parseInt(`${props.height || 0, 10}`) || elRef.value.$el.clientHeight
const height = parseInt(`${props.height || 0}`, 10) || elRef.value.$el.clientHeight

return first + Math.ceil(height / __itemHeight.value)
}
Expand Down
5 changes: 0 additions & 5 deletions types/virtual-scroll.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ export interface AtVirtualScrollProps extends AtComponent {
*/
bench?: number | string;
/*
* 可视区域渲染的列表行数
* @default 5
*/
viewport?: number | string;
/*
* 列表单项高度,用于计算列表单项的 top 样式值,单位 px。必填
* @default undefined
* @required true
Expand Down

0 comments on commit d76edcd

Please sign in to comment.