Tropix126 / fluent-svelte

A faithful implementation of Microsoft's Fluent Design System in Svelte.
https://fluent-svelte.vercel.app
MIT License
612 stars 27 forks source link

Use scale instead of width and height for the knob of the ToggleSwitch #65

Open spidunno opened 1 month ago

spidunno commented 1 month ago

Before you start...

Description

Currently, the knob in the ToggleSwitch component, when hovered, changes its size by setting inline-size and block-size directly. This results in a slightly choppy looking animation (as CSS is snapping the size to individual pixels), and could also cause performance issues due to causing repaints. To fix this, you can use either scale: ... or transform: scale(...) to change the size smoothly and without directly setting the width and height.

Alternative solutions

No response

Relevant Assets

LEFT: Current Implementation. RIGHT: My implementation using scale. https://github.com/user-attachments/assets/f70d6706-9896-4d1f-949a-f0f70ae7655c

If you'd like the CSS of my implementation I'd be happy to share it, I'm just not happy with the quality of it.

JLAcostaEC commented 4 weeks ago

I'm working on a Fluent UI library for Svelte 5, and my implementation is like yours. I hope to release an alpha version within 1 month. It should have been sooner, but I was inactive for 3 months. I'm getting back to it now and I'm very focused on the components and then making the documentation page.

https://github.com/user-attachments/assets/2a12d86d-6ab1-4bb8-bdbb-c7bc95bc5b0f