Skip to content

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

@indianazhao

Description

@indianazhao

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;
    }
  }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions