From 30047f004e89cd7b70e8a25ba9ae1d5efe3a9983 Mon Sep 17 00:00:00 2001 From: Sina Date: Fri, 9 Jun 2017 16:28:31 +0430 Subject: [PATCH] fix(menu): rtl gesture for menu (#11830) * fix(menu): rtl fix for menu * disable PropertySpelling in scss-lint for this special case * Revert "disable PropertySpelling in scss-lint for this special case" This reverts commit 87c3302fc2a533e1d926e0ed4ec768b467081a93. * remove scss changes because of the conflict * Fix left (default) menu position * Revert "Fix left (default) menu position" This reverts commit f657369540ac909d127bb9fb09f632af3a545de5. * trim down ifs * remove unnecessary this --- src/components/menu/menu-gestures.ts | 8 ++++---- src/components/menu/menu.ts | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/menu/menu-gestures.ts b/src/components/menu/menu-gestures.ts index 65e738e1c4..72be2da681 100644 --- a/src/components/menu/menu-gestures.ts +++ b/src/components/menu/menu-gestures.ts @@ -57,14 +57,14 @@ export class MenuContentGesture extends SlideEdgeGesture { } onSlide(slide: SlideData, ev: any) { - const z = (this.menu.isRightSide ? slide.min : slide.max); + const z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max); const stepValue = (slide.distance / z); this.menu._swipeProgress(stepValue); } onSlideEnd(slide: SlideData, ev: any) { - let z = (this.menu.isRightSide ? slide.min : slide.max); + let z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max); const currentStepValue = (slide.distance / z); const velocity = slide.velocity; z = Math.abs(z * 0.5); @@ -89,7 +89,7 @@ export class MenuContentGesture extends SlideEdgeGesture { getElementStartPos(slide: SlideData, ev: any) { const menu = this.menu; - if (menu.isRightSide) { + if (menu.isRightSide !== this.plt.isRTL) { return menu.isOpen ? slide.min : slide.max; } // left menu @@ -98,7 +98,7 @@ export class MenuContentGesture extends SlideEdgeGesture { getSlideBoundaries(): { min: number, max: number } { const menu = this.menu; - if (menu.isRightSide) { + if (menu.isRightSide !== this.plt.isRTL) { return { min: -menu.width(), max: 0 diff --git a/src/components/menu/menu.ts b/src/components/menu/menu.ts index b896e88077..03ba844abe 100644 --- a/src/components/menu/menu.ts +++ b/src/components/menu/menu.ts @@ -490,10 +490,11 @@ export class Menu implements RootNode, MenuInterface, OnInit, OnDestroy { // user has finished dragging the menu const isRightSide = this.isRightSide; + const isRTL = this._plt.isRTL; const opening = !this.isOpen; const shouldComplete = (opening) - ? isRightSide ? shouldCompleteLeft : shouldCompleteRight - : isRightSide ? shouldCompleteRight : shouldCompleteLeft; + ? (isRightSide !== isRTL) ? shouldCompleteLeft : shouldCompleteRight + : (isRightSide !== isRTL) ? shouldCompleteRight : shouldCompleteLeft; this._getType().setProgressEnd(shouldComplete, stepValue, velocity, (isOpen: boolean) => { console.debug('menu, swipeEnd', this.side);