diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index baae6631d..44e58de0b 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -103,6 +103,8 @@ define([ var me = this, length = me.bar.tabs.length, barBounds = me.bar.$bar.get(0).getBoundingClientRect(); + me.leftBorder = barBounds.left; + me.rightBorder = barBounds.right; if (barBounds) { me.bounds = []; @@ -324,19 +326,30 @@ define([ function dragMove (event) { if (!_.isUndefined(me.drag)) { me.drag.moveX = event.clientX*Common.Utils.zoom(); - if (me.drag.moveX < me.tabBarRight && me.drag.moveX > me.tabBarLeft) { + if (me.drag.moveX < me.leftBorder) { + me.scrollLeft -= 20; + me.bar.$bar.scrollLeft(me.scrollLeft); + me.calculateBounds(); + } else if (me.drag.moveX < me.tabBarRight && me.drag.moveX > me.tabBarLeft) { var name = $(event.target).parent().data('label'), currentTab = _.findIndex(bar.tabs, {label: name}); - if (currentTab !== -1 && (me.bounds[currentTab].left - me.scrollLeft >= me.tabBarLeft)) { + if (currentTab === -1) { + bar.$el.find('li.mousemove').removeClass('mousemove right'); + me.drag.place = undefined; + } else if (me.bounds[currentTab].left - me.scrollLeft >= me.tabBarLeft) { me.drag.place = currentTab; $(event.target).parent().parent().find('li.mousemove').removeClass('mousemove right'); $(event.target).parent().addClass('mousemove'); } - } else if ((me.drag.moveX > me.lastTabRight - me.scrollLeft) && (me.tabBarRight >= me.lastTabRight - me.scrollLeft)) { //move to end of list, right border of the right tab is visible + } else if (me.drag.moveX > me.lastTabRight && Math.abs(me.tabBarRight - me.bounds[me.bar.tabs.length - 1].right) < 1) { //move to end of list, right border of the right tab is visible bar.$el.find('li.mousemove').removeClass('mousemove right'); bar.tabs[bar.tabs.length - 1].$el.addClass('mousemove right'); me.drag.place = bar.tabs.length; - } + } else if (me.drag.moveX - me.rightBorder > 3) { + me.scrollLeft += 20; + me.bar.$bar.scrollLeft(me.scrollLeft); + me.calculateBounds(); + } } } if (!_.isUndefined(bar) && !_.isUndefined(tabs) && bar.tabs.length > 1) {