Sha256: 3699d546a03f662d7399357fa7493c66b5511e361558619952408547f664b8fd

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

class UnderOs::Crop < UnderOs::UI::View
class Scroll < UOS::UI::Scroll
  attr_reader :image

  def initialize(options={})
    super options

    UnderOs::App.history.current_page._.automaticallyAdjustsScrollViewInsets = false

    self.minScale = 1.0
    self.maxScale = 3.0
    @_.decelerationRate = 0.2

    append @image = UOS::UI::Image.new

    self.zoomItem = @image
    self.on(:zoom) { centerContent }
  end

  def image=(src)
    @image.src = src
    self.scale = 1.0 and @resetting = nil if @resetting

    scale      = [self.size.x / src.size.width, self.size.y / src.size.height].min
    @new_size  = {x: src.size.width * scale * self.scale, y: src.size.height * scale * self.scale}

    @image.size      = @new_size
    self.contentSize = @new_size

    centerContent
  end

  def resetting!
    @resetting = true
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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