mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:39:36 -06:00
Correct user-card positioning for rtl layouts
This commit is contained in:
parent
0dfb9261ea
commit
1bdf43d5cc
@ -84,18 +84,32 @@ export default Discourse.View.extend(CleansUp, {
|
||||
},
|
||||
|
||||
_willShow(target) {
|
||||
//const direction = $('html').css('direction');
|
||||
if (!target) { return; }
|
||||
const width = this.$().width();
|
||||
|
||||
Ember.run.schedule('afterRender', () => {
|
||||
if (target) {
|
||||
let position = target.offset();
|
||||
if (position) {
|
||||
position.left += target.width() + 10;
|
||||
|
||||
const overage = ($(window).width() - 50) - (position.left + width);
|
||||
if (overage < 0) {
|
||||
position.left += overage;
|
||||
position.top += target.height() + 48;
|
||||
// Check for a right to left layout
|
||||
if (($('html').css('direction')) === 'rtl') {
|
||||
position.right = $(window).width() - position.left + 10;
|
||||
position.left = 'auto';
|
||||
const overage = ($(window).width() - 50) - (position.right + width);
|
||||
if (overage < 0) {
|
||||
position.right += overage;
|
||||
position.top += target.height() + 48;
|
||||
}
|
||||
} else { // The site direction is ltr
|
||||
position.left += target.width() + 10;
|
||||
|
||||
const overage = ($(window).width() - 50) - (position.left + width);
|
||||
if (overage < 0) {
|
||||
position.left += overage;
|
||||
position.top += target.height() + 48;
|
||||
}
|
||||
}
|
||||
|
||||
position.top -= $('#main-outlet').offset().top;
|
||||
|
Loading…
Reference in New Issue
Block a user