Skip to content

Commit

Permalink
fix(list): 优化 containerHeight 获取逻辑 (#2860)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Jan 22, 2024
1 parent 46199f8 commit 29893f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/packages/__VUE/list/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import NutScrollView from '../scroll-view/index.taro.vue';
import { useTaroRect } from '@/packages/utils/useTaroRect';
import { CachedPosition, CompareResult, binarySearch } from './type';
const { create } = createComponent('list');
const clientHeight = Taro.getSystemInfoSync().windowHeight || 667;
export default create({
components: {
Expand All @@ -61,8 +60,7 @@ export default create({
default: 5
},
containerHeight: {
type: [Number],
default: clientHeight
type: Number
},
estimateRowHeight: {
type: Number,
Expand All @@ -76,6 +74,7 @@ export default create({
emits: ['scrollUp', 'scrollDown', 'scrollBottom'],
setup(props, { emit }) {
const clientHeight = Taro.getSystemInfoSync?.()?.windowHeight || 667;
const list = ref(null) as Ref;
const phantom = ref(null) as Ref;
const actualContent = ref(null) as Ref;
Expand All @@ -90,7 +89,10 @@ export default create({
});
const getContainerHeight = computed(() => {
return Math.min(props.containerHeight, clientHeight);
if (props.containerHeight) {
return Math.min(props.containerHeight, clientHeight);
}
return clientHeight;
});
const visibleCount = computed(() => {
Expand Down
10 changes: 6 additions & 4 deletions src/packages/__VUE/list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { createComponent } from '@/packages/utils/create';
import { CachedPosition, CompareResult, binarySearch } from './type';
import { useRect } from '@/packages/utils/useRect';
const { create } = createComponent('list');
const clientHeight = document.documentElement.clientHeight || document.body.clientHeight || 667;
export default create({
props: {
Expand All @@ -29,8 +28,7 @@ export default create({
default: 5
},
containerHeight: {
type: [Number],
default: clientHeight
type: Number
},
height: {
type: Number,
Expand All @@ -44,6 +42,7 @@ export default create({
emits: ['scrollUp', 'scrollDown', 'scrollBottom'],
setup(props, { emit }) {
const clientHeight = document.documentElement.clientHeight || document.body.clientHeight || 667;
const list = ref(null) as Ref;
const phantom = ref(null) as Ref;
const actualContent = ref(null) as Ref;
Expand All @@ -57,7 +56,10 @@ export default create({
});
const getContainerHeight = computed(() => {
return Math.min(props.containerHeight, clientHeight);
if (props.containerHeight) {
return Math.min(props.containerHeight, clientHeight);
}
return clientHeight;
});
const visibleCount = computed(() => {
Expand Down

0 comments on commit 29893f5

Please sign in to comment.