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

Logical (writing direction aware) transitions #8679

Open
ramiroaisen opened this issue May 31, 2023 · 0 comments
Open

Logical (writing direction aware) transitions #8679

ramiroaisen opened this issue May 31, 2023 · 0 comments

Comments

@ramiroaisen
Copy link

ramiroaisen commented May 31, 2023

Describe the problem

I recently had to translate an app I'm writing to different languages, with different writing directions.
So I had to replace all of my fly transitions to use this logical_fly function instead of the fly transition provided by svelte.

import { fly } from "svelte/transition";

export const logical_fly: typeof fly = (node, params = {}) => {
  let { x, ...rest } = params;
  if(getComputedStyle(node).direction === "rtl") x = -x; 
  return fly(node, {
    ...rest,
    x,
  })
}

This a little example for explanaition only, a better approach could be taken, like handling vertical wiritng modes.

Describe the proposed solution

Extend the transitions with logical parameters that are writing direction aware.

export type FlyParams = {
   /// same old x, y, duration, etc
   /// and the new ones
  inline?: number,
  block?: number
}

This won't be a breaking change because if not provided, the logical parameters could be ignored

Alternatives considered

Do nothing and let this be solved in user code.

Importance

nice to have

@ramiroaisen ramiroaisen changed the title Logical (writing direction aware) transiitons Logical (writing direction aware) transitions May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants