Class: UnderOs::UI::Scroll

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/scroll.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Scroll

Returns a new instance of Scroll.



4
5
6
7
8
9
10
# File 'lib/under_os/ui/scroll.rb', line 4

def initialize(options={})
  super

  self.paging = options.delete(:paging)

  @_.delegate = self
end

Instance Method Details

#centerContentObject



53
54
55
56
57
58
59
60
61
# File 'lib/under_os/ui/scroll.rb', line 53

def centerContent
  left = @_.contentSize.width > @_.bounds.size.width ? 0 :
    (@_.bounds.size.width - @_.contentSize.width) * 0.5

  top  = @_.contentSize.height > @_.bounds.size.height ? 0 :
    (@_.bounds.size.height - @_.contentSize.height) * 0.5

  @_.contentInset = UIEdgeInsetsMake(top, left, top, left)
end

#contentOffsetObject



30
31
32
# File 'lib/under_os/ui/scroll.rb', line 30

def contentOffset
  UnderOs::Point.new(x: @_.contentOffset.x, y: @_.contentOffset.y)
end

#contentOffset=(*args) ⇒ Object



34
35
36
37
# File 'lib/under_os/ui/scroll.rb', line 34

def contentOffset=(*args)
  offset = UnderOs::Point.new(*args)
  @_.contentOffset = CGPointMake(offset.x, offset.y)
end

#contentSizeObject



21
22
23
# File 'lib/under_os/ui/scroll.rb', line 21

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

#contentSize=(*args) ⇒ Object



25
26
27
28
# File 'lib/under_os/ui/scroll.rb', line 25

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

#maxScaleObject



79
80
81
# File 'lib/under_os/ui/scroll.rb', line 79

def maxScale
  @_.maximumZoomScale
end

#maxScale=(scale) ⇒ Object



83
84
85
# File 'lib/under_os/ui/scroll.rb', line 83

def maxScale=(scale)
  @_.maximumZoomScale = scale
end

#minScaleObject



71
72
73
# File 'lib/under_os/ui/scroll.rb', line 71

def minScale
  @_.minimumZoomScale
end

#minScale=(scale) ⇒ Object



75
76
77
# File 'lib/under_os/ui/scroll.rb', line 75

def minScale=(scale)
  @_.minimumZoomScale = scale
end

#pagingObject



12
13
14
# File 'lib/under_os/ui/scroll.rb', line 12

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

#paging=(value) ⇒ Object



16
17
18
19
# File 'lib/under_os/ui/scroll.rb', line 16

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

#repaint(*args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/under_os/ui/scroll.rb', line 39

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

#scaleObject



63
64
65
# File 'lib/under_os/ui/scroll.rb', line 63

def scale
  @_.zoomScale
end

#scale=(scale) ⇒ Object



67
68
69
# File 'lib/under_os/ui/scroll.rb', line 67

def scale=(scale)
  @_.zoomScale = scale
end

#scrollViewDidZoom(scrollView) ⇒ Object



99
100
101
# File 'lib/under_os/ui/scroll.rb', line 99

def scrollViewDidZoom(scrollView)
  emit :zoom
end

#viewForZoomingInScrollView(scrollView) ⇒ Object



95
96
97
# File 'lib/under_os/ui/scroll.rb', line 95

def viewForZoomingInScrollView(scrollView)
  @zoomItem
end

#zoomItemObject



87
88
89
# File 'lib/under_os/ui/scroll.rb', line 87

def zoomItem
  @zoomItem
end

#zoomItem=(item) ⇒ Object



91
92
93
# File 'lib/under_os/ui/scroll.rb', line 91

def zoomItem=(item)
  @zoomItem   = item.is_a?(UnderOs::UI::View) ? item._ : item
end