Sha256: cd13e647aa06d63da104978b8696fb914f0b569185e8a0eeaca4f4714367f518

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

class Scroll < UnderOs::UI::View
  wraps UIScrollView, tag: :scroll

  def initialize(options={})
    super

    self.paging = options.delete(:paging)
  end

  def paging
    @paging == nil ? false : @paging
  end

  def paging=(value)
    @paging = value == true ? true : nil
    @_.pagingEnabled = paging
  end

  def contentSize
    UnderOs::Point.new(x: @_.contentSize.width, y: @_.contentSize.height)
  end

  def contentSize=(*args)
    size = UnderOs::Point.new(*args)
    @_.contentSize = CGSizeMake(size.x, size.y)
  end

  def repaint(*args)
    content_size = {}

    super *args do |styles|
      styles.reject do |key, value|
        if [:contentWidth, :contentHeight].include?(key)
          content_size[key] = value
        end
      end
    end

    self.style = content_size unless content_size.empty?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
under-os-1.1.0 lib/under_os/ui/scroll.rb
under-os-1.0.0 lib/under_os/ui/scroll.rb