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
This commit is contained in:
Sam Wilson 2022-03-25 10:51:08 +08:00
parent 6f938c74b4
commit 21b36a737d

View file

@ -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 );