mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-04-07 14:06:16 +08:00
fix scroll
This commit is contained in:
@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user