I tried various avenues to replicate the animation on this page
https://www.apple.com/services/
As you see, there are looping carousels consisting of thumbnails that move to the left (translateX). When you hover on them, their speed is slowed down by about half. This looks simple, but it turns out to be one of the most complex tasks I tried to achieve. I’ve tried.
.carousel {
animation-name: move-to-right
animation-duration: 5s;
}
.carousel:hover {
animation-duration: 10s;
}
it slows down the animation, but on mouse out, the carousels jump to the left. Pausing the animation on hover is very simple, but slowing it down, can’t find the correct way to do that.
2
Answers
By using the Web Animation API you can control the
playBackRate
of any animation (CSSanimation
ortransition
or WebAnimation
):To achieve smooth animation like apples , you can use css for movement and javascript for adjusting speed. If you only change animation-duration it causes jumping effect. With javascript you can dynamically slow down the carousel maintaining its current position.