feat(split): add right to left support

See https://github.com/nathancahill/split/issues/739
This commit is contained in:
Elian Doran
2025-10-21 18:06:51 +03:00
parent 8a3b6ea694
commit 68033580a5
2 changed files with 5 additions and 0 deletions

View File

@@ -44,6 +44,9 @@ declare namespace Split {
// Direction to split: horizontal or vertical.
direction?: 'horizontal' | 'vertical'
// If the UI is right-to-left. Affects the drag direction.
rtl?: boolean
// Cursor to display while dragging.
cursor?: string

View File

@@ -182,6 +182,7 @@ const Split = (idsOption, options = {}) => {
defaultElementStyleFn,
)
const gutterStyle = getOption(options, 'gutterStyle', defaultGutterStyleFn)
const rtl = getOption(options, 'rtl', false)
// 2. Initialize a bunch of strings based on the direction we're splitting.
// A lot of the behavior in the rest of the library is paramatized down to
@@ -621,6 +622,7 @@ const Split = (idsOption, options = {}) => {
// if the parent has a reverse flex-direction, switch the pair elements.
if (
(direction === HORIZONTAL && rtl) ||
parentFlexDirection === 'row-reverse' ||
parentFlexDirection === 'column-reverse'
) {