Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(carousel): optimize flashing when sliding #647

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ exports[`Carousel style render correctly 1`] = `
exports[`Carousel swipeable 1`] = `
<Carousel
activeIndex={0}
animationDuration={300}
animationDuration={500}
autoPlay={false}
autoPlayIntervalTime={3000}
direction="left"
Expand Down
2 changes: 1 addition & 1 deletion packages/zarm/src/carousel/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ReactDOM.render(
| autoPlayIntervalTime | number | 3000 | 自动轮播时间间隔,单位:毫秒 |
| moveDistanceRatio | number | 0.5 | 移动距离比例临界点 |
| moveTimeSpan | number | 300 | 移动时间跨度临界点,单位:毫秒 |
| animationDuration | number | 300 | 动画执行时间,单位:毫秒 |
| animationDuration | number | 500 | 动画执行时间,单位:毫秒 |
| showPagination | boolean | true | 是否显示分页器 |
| onChange | (activeIndex?: number) => void | - | 值变化时触发的回调函数 |
| onChangeEnd | (activeIndex?: number) => void | - | 值变化动画结束后触发的回调函数 |
2 changes: 1 addition & 1 deletion packages/zarm/src/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Carousel extends Component<CarouselProps, any> {
height: 160,
loop: false,
activeIndex: 0,
animationDuration: 300,
animationDuration: 500,
swipeable: true,
autoPlay: false,
autoPlayIntervalTime: 3000,
Expand Down
15 changes: 13 additions & 2 deletions packages/zarm/src/carousel/style/component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
position: relative;
overflow: hidden;

@include e(items) {
display: flex;
transform-style: preserve-3d;
transition-property: transform;
}

@include e(item) {
display: inline-block;
flex-shrink: 0;
position: relative;
width: 100%;
height: 100%;
vertical-align: top;
transition-property: transform;
}

@include e(pagination) {
Expand All @@ -25,7 +33,6 @@

@include m(horizontal) {
@include e(items) {
will-change: transform;
white-space: nowrap;
}

Expand All @@ -47,6 +54,10 @@
}

@include m(vertical) {
@include e(items) {
flex-direction: column;
}

@include e(pagination) {
top: 50%;
right: var(--carousel-pagination-distance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ exports[`ImagePreview snapshot renders correctly 1`] = `
>
<Carousel
activeIndex={0}
animationDuration={300}
animationDuration={500}
autoPlay={false}
autoPlayIntervalTime={3000}
direction="left"
Expand Down Expand Up @@ -536,7 +536,7 @@ exports[`ImagePreview snapshot renders correctly with origin 1`] = `
>
<Carousel
activeIndex={0}
animationDuration={300}
animationDuration={500}
autoPlay={false}
autoPlayIntervalTime={3000}
direction="left"
Expand Down