Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue666 committed Oct 10, 2023
2 parents a73187c + aa03c87 commit d9fd16f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/components/Container/src/ScrollContainer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<Scrollbar ref="scrollbarRef" class="scroll-container" v-bind="$attrs">
<Scrollbar
ref="scrollbarRef"
class="scroll-container"
:scrollHeight="scrollHeight"
v-bind="$attrs"
>
<slot></slot>
</Scrollbar>
</template>
Expand All @@ -13,6 +18,9 @@
export default defineComponent({
name: 'ScrollContainer',
components: { Scrollbar },
props: {
scrollHeight: { type: Number },
},
setup() {
const scrollbarRef = ref<Nullable<ScrollbarType>>(null);
Expand Down
12 changes: 6 additions & 6 deletions src/components/Modal/src/components/ModalWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ScrollContainer ref="wrapperRef">
<ScrollContainer ref="wrapperRef" :scrollHeight="realHeight">
<div ref="spinRef" :style="spinStyle" v-loading="loading" :loading-tip="loadingTip">
<slot></slot>
</div>
Expand Down Expand Up @@ -49,7 +49,7 @@
const realHeightRef = ref(0);
const minRealHeightRef = ref(0);
let realHeight = 0;
const realHeight = ref(0);
let stopElResizeFn: AnyFunction = () => {};
Expand Down Expand Up @@ -145,7 +145,7 @@
if (!spinEl) return;
await nextTick();
// if (!realHeight) {
realHeight = spinEl.scrollHeight;
realHeight.value = spinEl.scrollHeight;
// }
if (props.fullScreen) {
Expand All @@ -154,17 +154,17 @@
} else {
realHeightRef.value = props.height
? props.height
: realHeight > maxHeight
: realHeight.value > maxHeight
? maxHeight
: realHeight;
: realHeight.value;
}
emit('height-change', unref(realHeightRef));
} catch (error) {
console.log(error);
}
}
return { wrapperRef, spinRef, spinStyle, scrollTop, setModalHeight };
return { wrapperRef, spinRef, spinStyle, scrollTop, setModalHeight, realHeight };
},
});
</script>
14 changes: 14 additions & 0 deletions src/components/Scrollbar/src/Scrollbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
provide,
computed,
unref,
watch,
} from 'vue';
import Bar from './bar';
Expand Down Expand Up @@ -64,6 +65,11 @@
type: String,
default: 'div',
},
scrollHeight: {
// 用于监控内部scrollHeight的变化
type: Number,
default: 0,
},
},
setup(props) {
const sizeWidth = ref('0');
Expand Down Expand Up @@ -99,6 +105,14 @@
sizeWidth.value = widthPercentage < 100 ? widthPercentage + '%' : '';
};
watch(
() => props.scrollHeight,
() => {
if (props.native) return;
update();
},
);
onMounted(() => {
if (props.native) return;
nextTick(update);
Expand Down

0 comments on commit d9fd16f

Please sign in to comment.