 
         
         super.prepareLayout()
-        println("prepareLayout")
+        println("prepareLayout ...")
 
-        self.sectionHeadersAttributes.removeAll(keepCapacity: true)
-        self.offsets.removeAllObjects()
+        calculateHeaders()
+
         
-        let cv = self.collectionView!
-        
-        let numberOfSections = cv.numberOfSections()
-        for var section = 0; section < numberOfSections; ++section {
-            
-            let attr =  super.layoutAttributesForSupplementaryViewOfKind(UICollectionElementKindSectionHeader,atIndexPath:NSIndexPath(forItem: 0, inSection: section))
-            self.sectionHeadersAttributes.append(attr)
-            
-            if (section > 0){
-                self.offsets.addObject(attr.frame.origin.y)
-            }
-        }
+//        
+//        let offset:CGFloat = collectionView.contentOffset.y + collectionView.contentInset.top
+//        let index = indexForOffset(offset)
+//        self.setFloatingHeaderOffset(offset, forIndex: index)
+//        self.floatingSectionIndex = index
         
         // ПОДУМАТЬ -> тут добавить еще пересчет первого видимого!
         
         
         let stop = CFAbsoluteTimeGetCurrent()
-        println("init time = \(stop - start) ")
+        println("prepareLayout ... done in \(stop - start) sec")
     }
     
 }

    var sectionHeadersAttributes:Array<UICollectionViewLayoutAttributes!> = []
    let offsets = NSMutableOrderedSet()
    var floatingSectionIndex:Int! = nil
    
    override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool {
        return true
    }
    
    override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {

        let attrs = super.layoutAttributesForElementsInRect(rect)
        
        return attrs?.map() {
            
            (attribute) -> UICollectionViewLayoutAttributes in
            

        let attrs = self.sectionHeadersAttributes[forIndex]
        attrs.frame = CGRectMake(0, offset, attrs.frame.size.width, attrs.frame.size.height)
        attrs.zIndex = 1024
        println("SetOffset: \(offset) forIndex:\(forIndex)")
    }
    
//    override func targetContentOffsetForProposedContentOffset(proposedContentOffset: CGPoint) -> CGPoint {
//        <#code#>
//    }
    
    override func invalidationContextForBoundsChange(newBounds: CGRect) -> UICollectionViewLayoutInvalidationContext {
        
        
        var context = super.invalidationContextForBoundsChange(newBounds)
        if let width = self.previousWidth{
            if (width != newBounds.size.width){
                println("FORCE PREPARE LAYOUT width changed \(width) -> \(newBounds.size.width) newBounds = \(newBounds)")
                self.previousWidth = newBounds.size.width
                return context
            }
        }
        
        self.previousWidth = newBounds.size.width

        // здесь инвалидируем конкретный аттрибут - выставляем его новые значения!,
        let collectionView = self.collectionView!
        
        let offset:CGFloat = newBounds.origin.y + collectionView.contentInset.top
        let index = indexForOffset(offset)
  //      self.setFloatingHeaderOffset(offset, forIndex: index)
        

        var invalidatedIndexPaths = [NSIndexPath(forItem: 0, inSection:index)];

        if let floatingSectionIndex = self.floatingSectionIndex {
            if (self.floatingSectionIndex != index){
                invalidatedIndexPaths.append(NSIndexPath(forItem: 0, inSection:floatingSectionIndex))
