Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollTabIntoView(arg) won't work if arg is zero #55

Open
indianazhao opened this issue Oct 19, 2016 · 0 comments
Open

scrollTabIntoView(arg) won't work if arg is zero #55

indianazhao opened this issue Oct 19, 2016 · 0 comments

Comments

@indianazhao
Copy link

If the argInt is equal to zero, scrollTabIntoView will not scroll to the tab 0.
So I change the if-check from truthy value check if(argInt) to number check if(argInt>=0).

$scope.scrollTabIntoView = function(arg){
  if(!$scope.tabContainer || $scope.hideButtons)return;

  var argInt = parseInt(arg);
  var tabToScroll;

  // first we find the tab element.
  if(argInt>=0) { // scroll tab index into view
    var allTabs = $scope.tabContainer.querySelectorAll('ul.nav-tabs > li');
    if(allTabs.length > argInt) { // only if its really exist
      tabToScroll = allTabs[argInt];
    }
  } else { // scroll selected tab into view
    var activeTab = $scope.tabContainer.querySelector('li.active');
    if(activeTab) {
      tabToScroll = activeTab;
    }
  }
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant