Merge pull request #896 from atom/bo-is-visible-is-evil

Speed up pane swapping -- isVisible() is slow
This commit is contained in:
Ben Ogle
2013-09-27 15:05:47 -07:00
2 changed files with 16 additions and 2 deletions

View File

@@ -1175,7 +1175,7 @@ class Editor extends View
updateDisplay: (options={}) ->
return unless @attached and @activeEditSession
return if @activeEditSession.destroyed
unless @isVisible()
unless @isOnDom() and @isVisible()
@redrawOnReattach = true
return

View File

@@ -35,7 +35,21 @@ $.fn.isOnDom = ->
@closest(document.body).length is 1
$.fn.isVisible = ->
@is(':visible')
!@isHidden()
$.fn.isHidden = ->
# Implementation taken from jQuery's `:hidden` expression code:
# https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js
#
# We were using a pseudo selector: @is(':hidden'). But jQuery's pseudo
# selector code checks the element's webkitMatchesSelector, which is always
# false, and is really really really slow.
elem = this[0]
return null unless elem
elem.offsetWidth <= 0 and elem.offsetHeight <= 0
$.fn.isDisabled = ->
!!@attr('disabled')