Skip to content

Commit 6169944

Browse files
committed
Use transform rather than left to animate
1 parent cd999e6 commit 6169944

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/Carousel.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ const Rail = styled.div`
3232
display: grid;
3333
grid-column-gap: ${({ gap }) => `${gap}px`};
3434
position: relative;
35-
transition: left 0.5s cubic-bezier(0.2, 1, 0.3, 1) 0s;
35+
transition: transform 0.5s cubic-bezier(0.2, 1, 0.3, 1) 0s;
3636
grid-template-columns: ${({ page }) => `repeat(${page}, 100%)`};
37-
left: ${({ currentPage, gap }) =>
38-
`calc(${-100 * currentPage}% - ${gap * currentPage}px)`};
37+
transform: ${({ currentPage, gap }) =>
38+
`translateX(calc(${-100 * currentPage}% - ${gap * currentPage}px))`};
3939
4040
@media screen and (max-width: ${({ mobileBreakpoint }) =>
4141
mobileBreakpoint}px) {
4242
padding-left: ${({ gap }) => `${gap}px`};
4343
grid-template-columns: ${({ page }) => `repeat(${page}, 90%)`};
4444
grid-column-gap: ${({ cols, rows, gap }) =>
4545
`calc(${(cols * rows - 1) * 90}% + ${cols * rows * gap}px)`};
46-
left: 0;
46+
transform: translateX(0);
4747
}
4848
`
4949

0 commit comments

Comments
 (0)