fix scroll

This commit is contained in:
Dmitry-Ilyushechkin
2024-11-25 15:40:22 +03:00
parent ac7952fcb5
commit c8302be9a7

View File

@ -528,43 +528,83 @@ define([
}
var rightbound = this.$bar.width(),
tab, right, left;
if (index == 'forward') {
for (var i = 0; i < this.tabs.length; i++) {
tab = this.tabs[i].$el;
right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width'));
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (this.$bar.width() > 400 ? 20 : 5));
this.checkInvisible(suppress);
break;
if (this.isRTL) {
if (index == 'forward') {
for (var i = this.tabs.length - 1; i >= 0; i--) {
tab = this.tabs[i].$el;
right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width'));
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (rightbound > 400 ? 20 : 5));
this.checkInvisible(suppress);
break;
}
}
}
}
} else if (index == 'backward') {
for (i = this.tabs.length; i-- > 0; ) {
tab = this.tabs[i].$el;
left = Common.Utils.getPosition(tab).left;
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
break;
else if (index == 'backward') {
for (var i = 0; i < this.tabs.length; i++) {
tab = this.tabs[i].$el;
left = Common.Utils.getPosition(tab).left;
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
break;
}
}
}
else if (typeof index == 'number') {
tab = this.tabs[index].$el;
left = Common.Utils.getPosition(tab).left;
right = left + parseInt(tab.css('width'));
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20);
this.checkInvisible(suppress);
} else if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
}
}
} else {
if (index == 'forward') {
for (var i = 0; i < this.tabs.length; i++) {
tab = this.tabs[i].$el;
right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width'));
if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (this.$bar.width() > 400 ? 20 : 5));
this.checkInvisible(suppress);
break;
}
}
} else if (index == 'backward') {
for (i = this.tabs.length; i-- > 0; ) {
tab = this.tabs[i].$el;
left = Common.Utils.getPosition(tab).left;
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
break;
}
}
} else if (typeof index == 'number') {
tab = this.tabs[index].$el;
left = Common.Utils.getPosition(tab).left;
right = left + parseInt(tab.css('width'));
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
} else if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20);
this.checkInvisible(suppress);
}
}
}
} else if (typeof index == 'number') {
tab = this.tabs[index].$el;
left = Common.Utils.getPosition(tab).left;
right = left + parseInt(tab.css('width'));
if (left < 0) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26);
this.checkInvisible(suppress);
} else if (right > rightbound) {
this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20);
this.checkInvisible(suppress);
}
}
}
},
},
checkInvisible: function(suppress) {
var result = {