Sitelet https://github.com/angular-split/angular-split/commit/97aa0e3863e9129f4e1da165be894b429c47039c
Skip to content

Commit 97aa0e3

Browse files
authored
fix: handle rtl in vertical direction correctly (#335)
1 parent 5e61233 commit 97aa0e3

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
7+
"lib-start": "ng build angular-split --watch",
78
"lint": "ng lint",
89
"app_build": "yarn lib_build && ng build --configuration production --base-href /angular-split/",
910
"app_analyze": "yarn lib_build && ng build --configuration production --stats-json && webpack-bundle-analyzer dist/angular-split-app/stats.json",

‎projects/angular-split/src/lib/component/split.component.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,13 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
687687

688688
let offset =
689689
this.direction === 'horizontal' ? this.startPoint.x - this.endPoint.x : this.startPoint.y - this.endPoint.y
690-
if (this.dir === 'rtl') {
690+
691+
// RTL requires negative offset only in horizontal mode as in vertical
692+
// RTL has no effect on drag direction.
693+
if (this.dir === 'rtl' && this.direction === 'horizontal') {
691694
offset = -offset
692695
}
696+
693697
const steppedOffset = Math.round(offset / this.gutterStep) * this.gutterStep
694698

695699
if (steppedOffset === this.snapshot.lastSteppedOffset) {

‎src/app/examples/dir-rtl/dir-rtl.component.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ import { AComponent } from '../../ui/components/AComponent'
1616
align-items: center;
1717
flex-wrap: wrap;
1818
}
19+
20+
.btns > button:not(:last-child) {
21+
margin-right: 10px;
22+
}
1923
`,
2024
],
2125
template: `
2226
{{ testChangeDetectorRun() }}
2327
<div class="container">
2428
<sp-example-title [type]="exampleEnum.DIR"></sp-example-title>
2529
<div class="split-example">
26-
<as-split [dir]="dir">
30+
<as-split [dir]="dir" [direction]="direction">
2731
<as-split-area size="20">
2832
<p>
2933
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tiam, quis nostrud exercitation
@@ -62,10 +66,14 @@ import { AComponent } from '../../ui/components/AComponent'
6266
<button class="btn btn-warning" (click)="dir = dir === 'rtl' ? 'ltr' : 'rtl'">
6367
{{ 'Toggle dir: "' + dir + '"' }}
6468
</button>
69+
<button class="btn btn-warning" (click)="direction = direction === 'vertical' ? 'horizontal' : 'vertical'">
70+
{{ 'Toggle direction: "' + direction + '"' }}
71+
</button>
6572
</div>
6673
</div>
6774
`,
6875
})
6976
export class DirRtlComponent extends AComponent {
7077
dir = 'rtl'
78+
direction = 'horizontal'
7179
}

0 commit comments

Comments
 (0)