This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class SleepLogCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
override func targetContentOffset( | |
forProposedContentOffset proposedContentOffset: CGPoint, | |
withScrollingVelocity velocity: CGPoint | |
) -> CGPoint { | |
var _proposedContentOffset = CGPoint( | |
x: proposedContentOffset.x, y: proposedContentOffset.y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class @LazyLoader | |
# Queue that lazily constructs new items only as required to keep the buffers full | |
# If objects in the queue back a corresponding view, they should implement a destroy_view() function so that they can be properly garbage collected | |
# - object_constructor should be a function that accepts a single argument - the index of the newly constructed object | |
# - buffer_size is the number of prev and next items to keep continuously populated | |
# - initial_index is the index of the initial object to construct | |
constructor: (@obj_constructor, @buffer_size, initial_index) -> | |
@prev_objs = [] | |
@next_objs = [] |