Class: MotionPrime::CollectionDelegate

Inherits:
Object
  • Object
show all
Includes:
DelegateMixin
Defined in:
motion-prime/sections/collection/collection_delegate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DelegateMixin

#clear_delegated, #delegated_by

Constructor Details

#initialize(options) ⇒ CollectionDelegate

Returns a new instance of CollectionDelegate.



6
7
8
9
# File 'motion-prime/sections/collection/collection_delegate.rb', line 6

def initialize(options)
  self.collection_section = options[:section].try(:weak_ref)
  @section_instance = collection_section.to_s
end

Instance Attribute Details

#collection_sectionObject

Returns the value of attribute collection_section.



4
5
6
# File 'motion-prime/sections/collection/collection_delegate.rb', line 4

def collection_section
  @collection_section
end

Instance Method Details

#collectionView(table, didSelectItemAtIndexPath: index) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'motion-prime/sections/collection/collection_delegate.rb', line 20

def collectionView(table, cellForItemAtIndexPath: index)
  cur_call_time = Time.now.to_f
  cur_call_offset = table.contentOffset.y
  if @prev_call_time
    time_delta = cur_call_time - @prev_call_time
    offset_delta = cur_call_offset - @prev_call_offset
    @deceleration_speed = offset_delta/time_delta
  end
  @prev_call_time = cur_call_time
  @prev_call_offset = cur_call_offset

  collection_section.cell_for_index(index)
end

#numberOfSectionsInCollectionView(table) ⇒ Object

def dealloc

pp 'Deallocating collection_delegate for ', @section_instance
super

end



16
17
18
# File 'motion-prime/sections/collection/collection_delegate.rb', line 16

def numberOfSectionsInCollectionView(table)
  collection_section.number_of_groups
end

#scrollViewDidEndDecelerating(scroll) ⇒ Object



54
55
56
# File 'motion-prime/sections/collection/collection_delegate.rb', line 54

def scrollViewDidEndDecelerating(scroll)
  collection_section.scroll_view_did_end_decelerating(scroll)
end

#scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate) ⇒ Object



58
59
60
# File 'motion-prime/sections/collection/collection_delegate.rb', line 58

def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate)
  collection_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate)
end

#scrollViewDidScroll(scroll) ⇒ Object



46
47
48
# File 'motion-prime/sections/collection/collection_delegate.rb', line 46

def scrollViewDidScroll(scroll)
  collection_section.scroll_view_did_scroll(scroll)
end

#scrollViewWillBeginDragging(scroll) ⇒ Object



50
51
52
# File 'motion-prime/sections/collection/collection_delegate.rb', line 50

def scrollViewWillBeginDragging(scroll)
  collection_section.scroll_view_will_begin_dragging(scroll)
end