Skip to content

Commit ea6450e

Browse files
John-Lukebrandyscarney
authored andcommitted
fix(item-options): improve rtl support (#11188)
* fix(item): Initial version of better rtl support for sliding items *Note:* need tests * Update item-options.ts * fix(item-options): fix changes requested
1 parent feeb267 commit ea6450e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/item/item-options.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Directive, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';
22

3+
import { Platform } from '../../platform/platform';
34
import { isPresent} from '../../util/util';
45
import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-sliding';
56

@@ -39,16 +40,25 @@ export class ItemOptions {
3940
*/
4041
@Output() ionSwipe: EventEmitter<ItemSliding> = new EventEmitter<ItemSliding>();
4142

42-
constructor(private _elementRef: ElementRef, private _renderer: Renderer) {}
43+
constructor(private _elementRef: ElementRef, private _renderer: Renderer, private _plt: Platform) {}
4344

4445
/**
4546
* @hidden
4647
*/
4748
getSides(): number {
48-
if (isPresent(this.side) && this.side === 'left') {
49-
return ITEM_SIDE_FLAG_LEFT;
49+
if (isPresent(this.side)) {
50+
switch (this.side) {
51+
case 'left':
52+
return ITEM_SIDE_FLAG_LEFT;
53+
case 'right':
54+
return ITEM_SIDE_FLAG_RIGHT;
55+
case 'start':
56+
return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT;
57+
case 'end':
58+
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
59+
}
5060
}
51-
return ITEM_SIDE_FLAG_RIGHT;
61+
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
5262
}
5363

5464
/**

0 commit comments

Comments
 (0)