Open GoodBoyNinja opened 9 months ago
Probably has a lot to do with requestAnimationFrame. MDN says "The frequency of calls to the callback function will generally match the display refresh rate." So on the 120Hz display, the spring's tick_spring
method is called twice as often and therefore ends up reaching the target value sooner. I haven't dived deep into the transitions code, but I do see a lot of hardcoded 60's in src/motion/spring.js
, so there might be an assumption of a 60Hz refresh rate baked into the spring code that needs to change.
There's currently a large PR outstanding to refactor rendering and transitions: https://github.com/sveltejs/svelte/pull/10594. It's very likely that a bugfix for the spring code will have to wait untli that PR is finished.
Probably has a lot to do with requestAnimationFrame. MDN says "The frequency of calls to the callback function will generally match the display refresh rate." So on the 120Hz display, the spring's
tick_spring
method is called twice as often and therefore ends up reaching the target value sooner. I haven't dived deep into the transitions code, but I do see a lot of hardcoded 60's insrc/motion/spring.js
, so there might be an assumption of a 60Hz refresh rate baked into the spring code that needs to change.
Thanks for taking a look. I don't have a lot to add , just mentioning some related lines if someone else wants to take a look at it in the future
Describe the bug
After creating an element with
spring
stores used for coordinates, testing the animation on different displays results in a noticeably different animation.My animation on an m1 pro MacBook pro 120hz display: https://github.com/sveltejs/svelte/assets/66829812/6eb6c1ba-8beb-46da-9fcb-81a950e02e54
The same animation on a 60hz external display: https://github.com/sveltejs/svelte/assets/66829812/3f98b357-36b5-4aab-a6fe-04600c09d028
The same animation on the 60hz display resolves much slower.
Reproduction
I found this REPL online, where the same behavior can be observed when testing on both a 60hz and a 160hz display https://svelte.dev/repl/spring?version=4.2.12
Logs
No response
System Info
Severity
annoyance