Skip to content

Commit

Permalink
fix(Noticebar): 修复Noticebar组件中vertical垂直滚动的公告,在滚动过程中会出现文字遮挡的缺陷 (#1051)
Browse files Browse the repository at this point in the history
* fix(Noticebar): 修复Noticebar组件中vertical垂直滚动的公告,在滚动过程中会出现文字遮挡的缺陷

* test: update snapshots

---------

Co-authored-by: anlyyao <anly_yaw@163.com>
  • Loading branch information
Gvonte and anlyyao authored Aug 22, 2023
1 parent d5025f4 commit b2f944c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/swiper/swiper-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ const direction = computed(() => (isVertical.value ? 'Y' : 'X'));
const calcTranslateStyle = (index: number, activeIndex: number) => {
const distance = root.value?.[isVertical.value ? 'offsetHeight' : 'offsetWidth'] ?? 0;
const lastItemIndex = items.value.length - 1;
let step = Math.min(index + 1, Math.abs(activeIndex - index));
if (activeIndex === index) step = 0;
else if (index === activeIndex + 1 || (loop && activeIndex === lastItemIndex && index === 0)) step = 1;
else if (index === activeIndex - 1 || (loop && activeIndex === 0 && index === lastItemIndex)) step = -1;
const step = activeIndex === lastItemIndex && index === 0 ? 1 : index - activeIndex;
rootStyle.value = `transform: translate${direction.value}(${step * distance}px)`;
};
Expand Down

0 comments on commit b2f944c

Please sign in to comment.