-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Inconsistent animation speed depending on monitor refresh rate #387
Comments
Hi @macjuul, Yep, I actually already have this on my to do so thank you for creating this issue 👍🏻. I’ll let you know when I have something. Best, |
Anyway we could add the ability to adjust the ease type? Using different easings with the autoplay plugin would be a win! Update: I realized all I needed to do is adjust the timing on the container via css. I'm using tailwind and adding the following class to the inner container div made things much smoother.
|
Hey @davidjerleke, have you had any time to look into this yet? or perhaps an estimate on when this could be tackled? Thanks! |
Hi @macjuul, Thanks for the follow up. I can’t give proper time estimates because I’m the sole dev on this project with a huge to do list, and I’m maintaining this on my spare time which means a little bit here and there. But what I can say is that I have it planned for the
Best, |
Great to hear @davidjerleke! Thanks for the heads up, looking forward to a fix. Take your time, no need to hurry 🙂 |
@macjuul, just wanted to let you know that I will start working on this issue the next time I work on this project. Can’t give an ETA though but I will start looking into it. |
Hi @macjuul, If you want to help out and speed up the process, you could test this CodeSandbox on:
The total runtime for the animation on each device should be something around If that's the case, I have a good starting point and will continue implementing this feature into the Embla Carousel core. Also note that the runtime won't be exactly 1500 and may slightly vary from one try to another (about 30 milliseconds give and take). Thanks in advance. |
This is indeed working perfectly on 144hz, 60hz, and 30hz. Good job! |
@macjuul, thanks for taking time and testing it out 👍. I'll let you know when I have a working frame rate agnostic Embla draft. |
Hi @macjuul and anyone tracking this issue. I’m done implementing this feature and it will be released with v8.0.0-rc01 pretty soon. I just have to update some examples on the documentation website. Stay tuned. Best, |
To be released with v8.0.0-rc01. |
@macjuul this feature has been released with v8.0.0-rc01. |
This library feels extremely slow for some reason on iOS 120 Hz still |
@bugproof it's hard to know what you mean with extremely slow because it's highly subjective, but the whole point with refresh rate agnostic animations, is that the animation duration should be the same regardless of monitor refresh rate. Otherwise the duration option would be highly unpredictable:
Instead it should be (like it's designed now):
You can easily test the speed with this code: let startTime = 0
emblaApi.on('settle', () => {
const nowTime = new Date().getTime()
const diffTime = nowTime - startTime
console.log(`Transition took ${diffTime}ms`)
})
function scrollNextWithTimer() {
startTime = new Date().getTime()
emblaApi.scrollNext()
}
scrollNextWithTimer() When you try that on monitors with different refresh rates, the animation should take approximately the same time, with an acceptable diff of 1-50 ms (because of how |
@davidjerleke the animation is not fluid on iOS browsers - it doesn't seem like 120hz. I compared it across few different libraries. https://blaze-slider.dev/ (has it's own issues and unmaintained but animations are very fluid) Those libs also use If you use or ever used airbnb, they also have carousel component on mobile in reviews section, now compare embla-carousel to that on iOS and you will see what I mean. I didn't test how it looks on android devices.
So to my understanding it is locked to 60hz and doesn't take advantage of high refresh rate screens |
Not sure how to describe it. It's not stuttering. It's like using 60hz display instead of the 120hz one. I tested it on both examples page and my own project. Maybe I can record it but I don't know if recording will capture it. |
@bugproof please help me understand you better by being more precise with your words. Example: Smooth or fluid animations: In my world, this means that the animation is continuous/fluid from point A to B, doesn’t stutter and isn’t choppy, regardless of the animation speed. Be it a slow or fast animation. So based on that definition, is it stuttering? Or is the animation still smooth/fluid, but you think it feels like the animation is taking too long on a 120hz screen? |
Then by your definition it's choppy/stuttering. It't not about animation speed but the way it runs on 120hz.
I don't think so I tried playing with duration but it didn't help. You can easily compare other carousels if you own iOS device. In my case I was testing it on a brave browser. |
@bugproof could you provide a screen recording? And which Apple device are you using? Please share both hardware and software versions. Additionally, please answer my previous question about where you’re testing? Is it the examples page on the website? |
I use iPhone 13 pro. On the screen recording it's not visible as the recording has a fixed frame rate. I would need to record the physical screen with some other phone perhaps. Yes I tested in the examples page you've linked. |
@bugproof would you mind testing this sandbox on both |
Yes the same problem in that sandbox. The animation looks like it's skipping some frames and it's visible to the naked eye. On 60hz it's even worse but I almost never use 60hz anymore so I can't tell. |
@bugproof thanks. I’ll look into it when I get the chance. It’s a bug in that case. |
Also both blaze slider and the other slider I have tried don't have this issue. The sliding animation there is buttery smooth almost like it was a native iOS app. |
@bugproof I know what the problem is. I don’t have access to 120hz screens so that’s why I couldn’t test this. But you’ve helped me narrow down the bug. |
@bugproof would you mind helping out one more time and try this CodeSandbox to see if the animation is smooth on your 120hz devices? |
Just tried it. Works slightly better I think? Still not as silky smooth as other libs from my list. |
@macjuul or anyone else with a refresh rate higher than |
Bug is related to
Embla Carousel version
Describe the bug
scrollTo
is affected by the refresh rate of your monitor. In my case, carousels will animate more than twice as fast on 144hz monitors compared to 60hz monitors, causing it to either feel to slow or too fast.CodeSandbox
Steps to reproduce
layout.frame_rate
to 30 inabout:config
)Expected behavior
Additional context
requestAnimationFrame
attempting to sync to the monitors refresh rate. This should be fixable by using the time value passed into the callback byrequestAnimationFrame
(Here's an explanation on StackOverflow)Thank you for your great library!
The text was updated successfully, but these errors were encountered: