       "visible"
 
   selectElement: (element, shouldScroll = true) ->
+    Common.log "selectElement #{element?} #{shouldScroll}" if @debug.select
+    Common.log "              #{element == @element} (expect false for a new element)" if @debug.select
     if element
       @clearSelection()
       @element = document.activeElement = element


    oldIndex = elements.indexOf @element
    newIndex = Math.max 0, Math.min elements.length - 1, oldIndex + 1

    if (@element and newIndex == oldIndex) or not elements[newIndex]
      element = @element ? document.body
      amount = 100 * if action == "up" then -1 else 1
      Scroller.scrollBy (@element ? document.body), "y", amount, true

      # perspective.
      if @element and newIndex != oldIndex
        { top, bottom } = @element.getBoundingClientRect()
        if action == "up" and top + 10 < @config.offset
          Common.log "  use previous element \"up\"" if @debug.select
          newIndex = oldIndex
        else if action == "down" and @config.offset + 10 < top
          Common.log "  use previous element \"down\"" if @debug.select
          newIndex = oldIndex

      Common.log "  scroll (element) #{elements[newIndex]?}" if @debug.select
      @selectElement elements[newIndex]

  eventToAction: do ->
