Improve positioning for content language selector on narrow screens
Reported in https://github.com/wikimedia/jquery.uls/pull/383#pullrequestreview-613761459 Instead of checking the left edge of the trigger, check the midpoint. This is more reliable and does not cause the dialog to incorrectly swap sides in narrow screens in LTR direction, This patch does not touch the compact language links variant. Bug: T276248 Change-Id: Ic734abb7b350852f8c5c10ced8456bf146df62d8
This commit is contained in:
@@ -76,8 +76,8 @@ function launchULS( $trigger, languagesObject, forCLS ) {
|
|||||||
width = $trigger.outerWidth();
|
width = $trigger.outerWidth();
|
||||||
height = $trigger.outerHeight();
|
height = $trigger.outerHeight();
|
||||||
|
|
||||||
if ( offset.left > $( window ).width() / 2 ) {
|
if ( offset.left + ( width / 2 ) > $( window ).width() / 2 ) {
|
||||||
// Trigger is on the right side of the viewport.
|
// Midpoint of the trigger is on the right side of the viewport.
|
||||||
this.$menu.css( {
|
this.$menu.css( {
|
||||||
left: 'auto',
|
left: 'auto',
|
||||||
// Right edge of the dialog aligns with the right edge of the trigger.
|
// Right edge of the dialog aligns with the right edge of the trigger.
|
||||||
@@ -85,7 +85,7 @@ function launchULS( $trigger, languagesObject, forCLS ) {
|
|||||||
top: offset.top + height
|
top: offset.top + height
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
// Trigger is on the left side of the viewport.
|
// Midpoint of the trigger is on the left side of the viewport.
|
||||||
this.$menu.css( {
|
this.$menu.css( {
|
||||||
// Left edge of the dialog aligns with the left edge of the trigger.
|
// Left edge of the dialog aligns with the left edge of the trigger.
|
||||||
left: offset.left,
|
left: offset.left,
|
||||||
|
|||||||
Reference in New Issue
Block a user