                     identifier: item.identifier,
                     renderer: item.renderer)
             }
-            selected = Int(items.centerIndex)
+            selectedIndex = Int(items.centerIndex)
             self.onSelectionChange = onSelectionChange
             super.init(items: items.map(transform), customComponentRenderer: customComponentRenderer, layoutEngine: layoutEngine, layout: layout)
-            scrollToItem(self.selected, animated: false)
+            scrollToItem(self.selectedIndex, animated: false)
         } else {
             self.onSelectionChange = onSelectionChange
             super.init(items: [], customComponentRenderer: customComponentRenderer, layoutEngine: layoutEngine, layout: layout)

    
    fileprivate let onSelectionChange: (ZipListShiftOperation) -> MessageType?
    fileprivate var lastOffset: CGFloat = 0
    fileprivate var selected: Int = 0
    
    public override init(items: [CollectionItemProperties<MessageType>], customComponentRenderer: CustomComponentRendererType, layoutEngine: LayoutEngine, layout: UICollectionViewLayout) {
        onSelectionChange = { _ in .none }

            return
        }
        
        let lastPosition = selectedIndex
        if currentOffset > lastOffset {
            if lastPosition < items.count - 1 {
                selectedIndex = lastPosition + 1 // Move to the right
                scrollToItem(selectedIndex, animated: true)
            }
        } else if currentOffset < lastOffset {
            if lastPosition >= 1 {
                selectedIndex = lastPosition - 1
                scrollToItem(selectedIndex, animated: true) // Move to the left
            }
        }
        let shift = shiftDirection(actual: selectedIndex, old: lastPosition)
        shift.flatMap(onSelectionChange) |> { mailbox.dispatch(message: $0) }
    }
    
