From e33e8c1f531f6c8a8899c0693d91911df78f3974 Mon Sep 17 00:00:00 2001 From: John-Luke Date: Tue, 11 Apr 2017 20:46:25 -0300 Subject: [PATCH 1/3] fix(item): Initial version of better rtl support for sliding items *Note:* need tests --- src/components/item/item-options.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/item/item-options.ts b/src/components/item/item-options.ts index 781a6bf60e5..bad25cc32d3 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,13 +40,19 @@ 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') { + if (isPresent(this.side) && this.side === 'left' && !_plt.isRTL()) { + return ITEM_SIDE_FLAG_LEFT; + } + else if (isPresent(this.side) && this.side === 'left' && _plt.isRTL()) { + return ITEM_SIDE_FLAG_RIGHT; + } + else if (isPresent(this.side) && this.side === 'right' && _plt.isRTL()) { return ITEM_SIDE_FLAG_LEFT; } return ITEM_SIDE_FLAG_RIGHT; From 69cfab7452747f1533ffd15094c97399a57fb3f1 Mon Sep 17 00:00:00 2001 From: John-Luke Date: Mon, 17 Apr 2017 11:12:06 -0300 Subject: [PATCH 2/3] Update item-options.ts --- src/components/item/item-options.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/item/item-options.ts b/src/components/item/item-options.ts index bad25cc32d3..d5ad27b0649 100644 --- a/src/components/item/item-options.ts +++ b/src/components/item/item-options.ts @@ -46,14 +46,17 @@ export class ItemOptions { * @hidden */ getSides(): number { - if (isPresent(this.side) && this.side === 'left' && !_plt.isRTL()) { - return ITEM_SIDE_FLAG_LEFT; - } - else if (isPresent(this.side) && this.side === 'left' && _plt.isRTL()) { - return ITEM_SIDE_FLAG_RIGHT; - } - else if (isPresent(this.side) && this.side === 'right' && _plt.isRTL()) { - 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 _plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT; + case 'end': + return _plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT; + } } return ITEM_SIDE_FLAG_RIGHT; } From ba703a4e479f04b1f2dec3d110fc455253f1e679 Mon Sep 17 00:00:00 2001 From: John-Luke Date: Mon, 17 Apr 2017 11:56:17 -0300 Subject: [PATCH 3/3] fix(item-options): fix changes requested --- src/components/item/item-options.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/item/item-options.ts b/src/components/item/item-options.ts index d5ad27b0649..3d9646a6a3d 100644 --- a/src/components/item/item-options.ts +++ b/src/components/item/item-options.ts @@ -47,18 +47,18 @@ export class ItemOptions { */ getSides(): number { if (isPresent(this.side)) { - switch(this.side) { + switch (this.side) { case 'left': return ITEM_SIDE_FLAG_LEFT; case 'right': return ITEM_SIDE_FLAG_RIGHT; case 'start': - return _plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT; + return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT; case 'end': - return _plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT; + 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; } /**