From 21b36a737dfb97cf7850d93d7b239b80474ec297 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Fri, 25 Mar 2022 10:51:08 +0800 Subject: [PATCH] Fix dragbar direction for RTL text direction Change the sign (positive/negative) of the change amount (in pixels) depending on whether the text direction is LTR or RTL. Bug: T304487 Change-Id: I8f01a92e5e1094c9602d2ff334c730241193cedc --- modules/realtimepreview/ResizingDragBar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/realtimepreview/ResizingDragBar.js b/modules/realtimepreview/ResizingDragBar.js index 3fc5be08..41eac29d 100644 --- a/modules/realtimepreview/ResizingDragBar.js +++ b/modules/realtimepreview/ResizingDragBar.js @@ -19,6 +19,8 @@ function ResizingDragBar( config ) { this.$element.addClass( classNameDir ); var resizingDragBar = this; + // Determine the horizontal direction to move (flexbox automatically reverses but the offset direction doesn't). + var rtlFactor = config.isEW && OO.ui.Element.static.getDir( document ) === 'rtl' ? -1 : 1; this.$element.on( 'mousedown', function ( eventMousedown ) { if ( eventMousedown.button !== ResizingDragBar.static.MAIN_MOUSE_BUTTON ) { // If not the main mouse (e.g. left) button, ignore. @@ -37,7 +39,7 @@ function ResizingDragBar( config ) { // Current position of the mouse (relative to page, not viewport). var newOffset = eventMousemove[ xOrY ]; // Distance the mouse has moved. - var change = lastOffset - newOffset; + var change = rtlFactor * ( lastOffset - newOffset ); // Set the new size of the pane, and tell others about it. var newSize = Math.max( startSize - change, ResizingDragBar.static.MIN_PANE_SIZE ); resizingDragBar.getResizedPane().css( widthOrHeight, newSize );