       unless clear
         timer = Common.setTimeout delay, =>
           timer = null
-          if @element and not Common.isInViewport @element
-            @clearSelection()
-          if not @element
+          if @element
+            unless Common.isInViewport(@element) and Common.isDisplayed @element
+              @clearSelection()
+          unless @element
             if element = (ele for ele in @getElements direction when Common.isInViewport ele)[0]
               @selectElement element, false
 

    @config.selectors ?= []

    chrome.runtime.sendMessage name: "icon", show: true if @config.selectors?
    if element
      @selectElement element, false
    else if element = @getElements("down")[0]
       @selectElement element, false

  deactivate: ->
    chrome.runtime.sendMessage name: "icon", show: false

          characterData: true
          subtree: true
        observeFunction = (mutations) =>
          if @element and @element == element and Common.isDisplayed(element) and Common.isInViewport element
            # We could probably be more selective as to the types of mutations for which we re-select the
            # current element.
            @selectElement element, false
          else
            # @clearSelection() has the side effect of disabling this mutation observer.
            @clearSelection()
      else
        observeFunction = null
