Skip to content

Commit

Permalink
fix: 修复tag变更时滚动最大值未更新错误
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Aug 18, 2023
1 parent 5a5fb0f commit ba38f08
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/layout/components/header/components/tagBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ const setScrollLeft = (left: number, isAdd = false) => {
}
$(scrollbarRef.value!.$el).find('.el-scrollbar__wrap').animate({ scrollLeft: left }, 300);
};
const max = ref(0);
const tagsRef = ref([] as HTMLElement[]);
const currentTag = ref<RouteLocationNormalized>({
fullPath: '/',
meta: { title: '' },
} as RouteLocationNormalized);
const route = useRoute();
onMounted(() => {
const max = ref(0);
const setMax = () => {
max.value = listRef.value!.offsetWidth - scrollbarRef.value?.$el.clientWidth;
mitter.on(
event.RESIZE,
() => {
max.value = listRef.value!.offsetWidth - scrollbarRef.value?.$el.clientWidth;
},
true,
);
};
onMounted(() => {
mitter.on(event.RESIZE, setMax, true);
watch(tags, setMax, {
flush: 'post',
immediate: true,
});
});
const back = () => {
setScrollLeft(0 - scrollbarRef.value!.$el.clientWidth / 2, true);
Expand All @@ -137,7 +137,7 @@ const jump = (index: number) => {
return;
}
if (index === tagsRef.value.length - 1) {
setScrollLeft(max.value);
max.value > 0 && setScrollLeft(max.value);
return;
}
const parentWidth = scrollbarRef.value!.$el.clientWidth;
Expand Down

0 comments on commit ba38f08

Please sign in to comment.