Skip to content
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

Feature: adds translate option to the useFloating hook #165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dvcol
Copy link

@dvcol dvcol commented Jan 15, 2025

The use of the transform property for positionning might interfer with animations or make merging of states complex.

For example, the use of a enter/exit animations such as the svlete native scale transition will overwrite the transform property during transition.

A workaround is to use absolute positioning, but this can also causes issues (e.g. content shift) and tends to be less performant.

This PR propose to uses the translate property instead which has achieved a high level of support (94-95%) in recent years.

This also adds transform-origin when using translate/transform to facilitate animation and transitions.

dvcol added 2 commits January 15, 2025 08:52
To not interfere with other transform animation, this allows to set the position state through the 'translate' property instead of 'transform'
To facilitate transition and animation, includes the transition-origin in the floating styles when using translate or transform
Copy link

changeset-bot bot commented Jan 15, 2025

⚠️ No Changeset found

Latest commit: 3c1c025

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
floating-ui-svelte ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 8:27am

@dvcol
Copy link
Author

dvcol commented Jan 15, 2025

Here a reproduction link in svelte playground.

And here a reproduction repo on github..

To replicate the issue, a refresh or a window resize is necessary.

@endigo9740 endigo9740 requested a review from Hugos68 January 15, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant