From ea6450e96ab9ced4fc9dd21a228fa94585f12132 Mon Sep 17 00:00:00 2001 From: John-Luke Date: Mon, 17 Apr 2017 12:32:04 -0300 Subject: [PATCH] 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 --- src/components/item/item-options.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/item/item-options.ts b/src/components/item/item-options.ts index 781a6bf60e5..3d9646a6a3d 100644 --- a/src/components/item/item-options.ts +++ b/src/components/item/item-options.ts @@ -1,5 +1,6 @@ import { Directive, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core'; +import { Platform } from '../../platform/platform'; import { isPresent} from '../../util/util'; import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-sliding'; @@ -39,16 +40,25 @@ export class ItemOptions { */ @Output() ionSwipe: EventEmitter = new EventEmitter(); - constructor(private _elementRef: ElementRef, private _renderer: Renderer) {} + constructor(private _elementRef: ElementRef, private _renderer: Renderer, private _plt: Platform) {} /** * @hidden */ getSides(): number { - if (isPresent(this.side) && this.side === 'left') { - return ITEM_SIDE_FLAG_LEFT; + if (isPresent(this.side)) { + switch (this.side) { + case 'left': + return ITEM_SIDE_FLAG_LEFT; + case 'right': + return ITEM_SIDE_FLAG_RIGHT; + case 'start': + return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT; + case 'end': + return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT; + } } - return ITEM_SIDE_FLAG_RIGHT; + return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT; } /**