Sha256: 7a413e91c943502543cfdf8f2fad8ff6beadf12f22d55edfc99e005c796d8454

Contents?: true

Size: 908 Bytes

Versions: 6

Compression:

Stored size: 908 Bytes

Contents

class UnderOs::UI::Sidebar < UnderOs::UI::View
  wraps UIView, tag: :sidebar

  LOCATIONS = [:top, :left, :right, :bottom]

  def initialize(options={})
    super

    self.location = options.delete(:location) if options.has_key?(:location)
  end

  def location
    @location || :bottom
  end

  def location=(value)
    @location = value.to_sym
    @location = nil if ! LOCATIONS.include?(@location)
  end

  def show
    class_names = self.classNames
    class_names.reject!{ |n| LOCATIONS.include?(n.to_sym) }

    self.classNames = class_names + [location, 'visible']
    self.style = {location => -slide_distance, display: :block}

    animate location => 0
  end

  def hide
    @_class_names -= ['visible']

    animate location => -slide_distance
  end

  def hidden
    !classNames.include?('visible')
  end

  def slide_distance
    [:top, :bottom].include?(location) ? size.y : size.x
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/ui/sidebar.rb
under-os-1.3.0 lib/under_os/ui/sidebar.rb
under-os-1.2.1 lib/under_os/ui/sidebar.rb
under-os-1.2.0 lib/under_os/ui/sidebar.rb
under-os-1.1.0 lib/under_os/ui/sidebar.rb
under-os-1.0.0 lib/under_os/ui/sidebar.rb