Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): prevents multiple pagination clicks during animation
Browse files Browse the repository at this point in the history
Closes #1207.
  • Loading branch information
Robert Messerle committed Jan 23, 2015
1 parent 7e8690d commit 299e155
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/tabs/js/paginationDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM
var tabs = element[0].getElementsByTagName('md-tab');
var debouncedUpdatePagination = $$rAF.debounce(updatePagination);
var tabsParent = element.children();
var locked = false;
var state = scope.pagination = {
page: -1,
active: false,
clickNext: function() { userChangePage(+1); },
clickPrevious: function() { userChangePage(-1); }
clickNext: function() { locked || userChangePage(+1); },
clickPrevious: function() { locked || userChangePage(-1); }
};

scope.$on('$mdTabsChanged', debouncedUpdatePagination);
Expand All @@ -47,7 +48,10 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM
} else {
// Go to the new page, wait for the page transition to end, then focus.
oldTab && oldTab.element.blur();
setPage(pageIndex).then(function() { tab.element.focus(); });
setPage(pageIndex).then(function() {
locked = false;
tab.element.focus();
});
}
}

Expand All @@ -57,6 +61,7 @@ function TabPaginationDirective($mdConstant, $window, $$rAF, $$q, $timeout, $mdM
var newPage = Math.max(0, Math.min(sizeData.pages.length - 1, state.page + increment));
var newTabIndex = sizeData.pages[newPage][ increment > 0 ? 'firstTabIndex' : 'lastTabIndex' ];
var newTab = tabsCtrl.itemAt(newTabIndex);
locked = true;
onTabFocus(newTab);
}

Expand Down

0 comments on commit 299e155

Please sign in to comment.