function navigate(dir) {
      if (!options.enableCellNavigation) {
        return false;
      }

      if (!activeCellNode && dir !== NAVIGATE_PREV && dir !== NAVIGATE_NEXT && dir !== NAVIGATE_HOME && dir !== NAVIGATE_END) {
if (0) {
        // See if a cell has focus and if so, use that one to base the move on;
        // otherwise simply scroll in the indicated direction if possible.
        assert(!activeCell);
        assert(!activeRow);
        assert(!getEditorLock().isActive());
        var focusedNode = getCellFromElement(document.activeElement);
        if (focusedNode) {
          setActiveCellInternal(focusedNode, {
            forceEditMode: null, 
            takeFocus: false
          });
          assert(activeCellNode);
          // and continue with the regular execution path for activeCellNode
        } else {
          // WARNING: the stepFunctions assume a starting coordinate to be valid
          // to that they can properly step through the col/rowspans. 
          // Today we are not located on a cell per se, so we simply move a
          // given number of rows/columns in the indicated direction.
          var visible = getVisibleRange();
          assert(visible);
          var left = getCellFromPoint(visible.topPx, visible.leftPx);
          var right = getCellFromPoint(visible.topPx, visible.rightPx);
          var row, cell;
          switch (dir) {
          case NAVIGATE_UP:
            row = visible.top - 1;
            if (row >= 0) {
              scrollRowIntoView(row, false, false);
            }
            break;

          case NAVIGATE_DOWN:
            row = visible.bottom + 1;
            if (row >= 0) {
              scrollRowIntoView(row, false, false);
            }
            visible.top += 1;
            visible.bottom += 1;
            break;

          case NAVIGATE_LEFT:
            visible.left -= 1;
            visible.right -= 1;
            break;

          case NAVIGATE_RIGHT:
            visible.left += 1;
            visible.right += 1;
            break;

          default:
            assert(0);
            break;
          }



        }
}

        return false;
      }

      if (!getEditorLock().commitCurrentEdit()) {
        return true;
      }

      tabbingDirection = tabbingDirections[dir];
      setFocus();

      var node;
      var stepFn = stepFunctions[dir];
      assert(activeRow != null);
      assert(activeCell != null);
      assert(activePosY != null);
      assert(activePosX != null);
      var pos = stepFn(activeRow, activeCell, activePosY, activePosX);
      if (pos) {
        assert(pos.row != null);
        assert(pos.cell != null);
        assert(pos.posX != null);
        assert(pos.posY != null);
        activePosY = pos.posY;
        activePosX = pos.posX;
        var isAddNewRow = (pos.row === getDataLength());
        scrollCellIntoView(pos.row, pos.cell, !isAddNewRow);
        node = getCellNode(pos.row, pos.cell, true);
        assert(node);
        setActiveCellInternal(node, {
          forceEditMode: null, 
          takeFocus: false
        });
        return true;
      } else if (activeCellNode) {
        node = getCellNode(activeRow, activeCell, true);
        assert(node);
        setActiveCellInternal(node, {
          forceEditMode: null, 
          takeFocus: false
        });
        return false;
      } else {
        assert(activeRow == null && activeCell == null);
        resetActiveCell();
        return false;
      }
    }
/**
     * @param {string} dir Navigation direction.
     * @return {boolean} Whether navigation resulted in a change of active cell.
     */
@param {string} dir Navigation direction.
@return {boolean} Whether navigation resulted in a change of active cell.
@param { string } dir Navigation direction . @return { boolean } Whether navigation resulted in a change of active cell .
function navigate(dir) {
      if (!options.enableCellNavigation) {
        return false;
      }
      if (!activeCellNode && dir !== NAVIGATE_PREV && dir !== NAVIGATE_NEXT && dir !== NAVIGATE_HOME && dir !== NAVIGATE_END) {
if (0) {
        assert(!activeCell);
        assert(!activeRow);
        assert(!getEditorLock().isActive());
        var focusedNode = getCellFromElement(document.activeElement);
        if (focusedNode) {
          setActiveCellInternal(focusedNode, {
            forceEditMode: null, 
            takeFocus: false
          });
          assert(activeCellNode);
        } else {
          var visible = getVisibleRange();
          assert(visible);
          var left = getCellFromPoint(visible.topPx, visible.leftPx);
          var right = getCellFromPoint(visible.topPx, visible.rightPx);
          var row, cell;
          switch (dir) {
          case NAVIGATE_UP:
            row = visible.top - 1;
            if (row >= 0) {
              scrollRowIntoView(row, false, false);
            }
            break;
          case NAVIGATE_DOWN:
            row = visible.bottom + 1;
            if (row >= 0) {
              scrollRowIntoView(row, false, false);
            }
            visible.top += 1;
            visible.bottom += 1;
            break;
          case NAVIGATE_LEFT:
            visible.left -= 1;
            visible.right -= 1;
            break;
          case NAVIGATE_RIGHT:
            visible.left += 1;
            visible.right += 1;
            break;
          default:
            assert(0);
            break;
          }
        }
}
        return false;
      }
      if (!getEditorLock().commitCurrentEdit()) {
        return true;
      }
      tabbingDirection = tabbingDirections[dir];
      setFocus();
      var node;
      var stepFn = stepFunctions[dir];
      assert(activeRow != null);
      assert(activeCell != null);
      assert(activePosY != null);
      assert(activePosX != null);
      var pos = stepFn(activeRow, activeCell, activePosY, activePosX);
      if (pos) {
        assert(pos.row != null);
        assert(pos.cell != null);
        assert(pos.posX != null);
        assert(pos.posY != null);
        activePosY = pos.posY;
        activePosX = pos.posX;
        var isAddNewRow = (pos.row === getDataLength());
        scrollCellIntoView(pos.row, pos.cell, !isAddNewRow);
        node = getCellNode(pos.row, pos.cell, true);
        assert(node);
        setActiveCellInternal(node, {
          forceEditMode: null, 
          takeFocus: false
        });
        return true;
      } else if (activeCellNode) {
        node = getCellNode(activeRow, activeCell, true);
        assert(node);
        setActiveCellInternal(node, {
          forceEditMode: null, 
          takeFocus: false
        });
        return false;
      } else {
        assert(activeRow == null && activeCell == null);
        resetActiveCell();
        return false;
      }
    }
function navigate ( dir ) { if ( ! options . enableCellNavigation ) { return false ; } if ( ! activeCellNode && dir !== NAVIGATE_PREV && dir !== NAVIGATE_NEXT && dir !== NAVIGATE_HOME && dir !== NAVIGATE_END ) { if ( 0 ) { assert ( ! activeCell ) ; assert ( ! activeRow ) ; assert ( ! getEditorLock ( ) . isActive ( ) ) ; var focusedNode = getCellFromElement ( document . activeElement ) ; if ( focusedNode ) { setActiveCellInternal ( focusedNode , { forceEditMode : null , takeFocus : false } ) ; assert ( activeCellNode ) ; } else { var visible = getVisibleRange ( ) ; assert ( visible ) ; var left = getCellFromPoint ( visible . topPx , visible . leftPx ) ; var right = getCellFromPoint ( visible . topPx , visible . rightPx ) ; var row , cell ; switch ( dir ) { case NAVIGATE_UP : row = visible . top - 1 ; if ( row >= 0 ) { scrollRowIntoView ( row , false , false ) ; } break ; case NAVIGATE_DOWN : row = visible . bottom + 1 ; if ( row >= 0 ) { scrollRowIntoView ( row , false , false ) ; } visible . top += 1 ; visible . bottom += 1 ; break ; case NAVIGATE_LEFT : visible . left -= 1 ; visible . right -= 1 ; break ; case NAVIGATE_RIGHT : visible . left += 1 ; visible . right += 1 ; break ; default : assert ( 0 ) ; break ; } } } return false ; } if ( ! getEditorLock ( ) . commitCurrentEdit ( ) ) { return true ; } tabbingDirection = tabbingDirections [ dir ] ; setFocus ( ) ; var node ; var stepFn = stepFunctions [ dir ] ; assert ( activeRow != null ) ; assert ( activeCell != null ) ; assert ( activePosY != null ) ; assert ( activePosX != null ) ; var pos = stepFn ( activeRow , activeCell , activePosY , activePosX ) ; if ( pos ) { assert ( pos . row != null ) ; assert ( pos . cell != null ) ; assert ( pos . posX != null ) ; assert ( pos . posY != null ) ; activePosY = pos . posY ; activePosX = pos . posX ; var isAddNewRow = ( pos . row === getDataLength ( ) ) ; scrollCellIntoView ( pos . row , pos . cell , ! isAddNewRow ) ; node = getCellNode ( pos . row , pos . cell , true ) ; assert ( node ) ; setActiveCellInternal ( node , { forceEditMode : null , takeFocus : false } ) ; return true ; } else if ( activeCellNode ) { node = getCellNode ( activeRow , activeCell , true ) ; assert ( node ) ; setActiveCellInternal ( node , { forceEditMode : null , takeFocus : false } ) ; return false ; } else { assert ( activeRow == null && activeCell == null ) ; resetActiveCell ( ) ; return false ; } }
@param {string} dir Navigation direction.
@param { string } dir Navigation direction .
// See if a cell has focus and if so, use that one to base the move on; // otherwise simply scroll in the indicated direction if possible. // and continue with the regular execution path for activeCellNode // WARNING: the stepFunctions assume a starting coordinate to be valid // to that they can properly step through the col/rowspans.  // Today we are not located on a cell per se, so we simply move a // given number of rows/columns in the indicated direction.