Module: Shoes::Common::Visibility

Instance Method Summary collapse

Instance Method Details

#hidden?Boolean Also known as: hidden

Root method for determining whether we’re visible or not, taking into account our parent chain’s visibility.

Returns:

  • (Boolean)


14
15
16
# File 'shoes-core/lib/shoes/common/visibility.rb', line 14

def hidden?
  (defined?(@parent) && @parent&.hidden?) || style[:hidden]
end

#hidden_from_view?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'shoes-core/lib/shoes/common/visibility.rb', line 24

def hidden_from_view?
  hidden? || outside_parent_view?
end

#hideObject

Hides the element, so that it can’t be seen. See also #show and #toggle.



7
8
9
10
# File 'shoes-core/lib/shoes/common/visibility.rb', line 7

def hide
  style(hidden: true)
  self
end

#outside_parent_view?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'shoes-core/lib/shoes/common/visibility.rb', line 28

def outside_parent_view?
  # Painted elements handle slot bounds themselves when painting
  return false if @parent.nil? || @parent.variable_height? || painted?

  # We hide when we're at all outside our parent's bounds
  !@parent.contains?(dimensions)
end

#showObject

Reveals the element, if it is hidden. See also #hide and #toggle.



37
38
39
40
# File 'shoes-core/lib/shoes/common/visibility.rb', line 37

def show
  style(hidden: false)
  self
end

#toggleObject

Hides an element if it is shown. Or shows the element, if it is hidden. See also #hide and #show.



44
45
46
47
# File 'shoes-core/lib/shoes/common/visibility.rb', line 44

def toggle
  style(hidden: !style[:hidden])
  self
end

#visible?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'shoes-core/lib/shoes/common/visibility.rb', line 20

def visible?
  !hidden?
end