code: function nextState(visobj, currentState) {
    var newState = visobj.state();
    var percentage = newState.percentage;
  
    // check if nothing changed
    if (currentState &&
      percentage === currentState.percentage &&
      currentState.percentage === currentState.previous.percentage) {
      return currentState;
    }
  
    if (newState.hidden) {
      return VisSense.VisState.hidden(percentage, currentState);
    }
    else if (newState.fullyvisible) {
      return VisSense.VisState.fullyvisible(percentage, currentState);
    }
  
    // otherwise the element is visible
    return VisSense.VisState.visible(percentage, currentState);
  }
docs: @private
  @function
  @name nextState
  
  @param {VisSense} visobj The VisSense element.
  @param {VisSense~VisState} [currentState] The current state. Can be omitted
  if the state of an element is determined the first time.
  
  @returns {VisSense~VisState} A visibility state object.
  
  This method determines and returns the new visibility state of an element.