         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 {
         
-//        println("invalidationContextForBoundsChange(\(newBounds))")
         
         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)];
-        
-        self.setFloatingHeaderOffset(offset, forIndex: index)
-        
+
         if let floatingSectionIndex = self.floatingSectionIndex {
             if (self.floatingSectionIndex != index){
                 invalidatedIndexPaths.append(NSIndexPath(forItem: 0, inSection:floatingSectionIndex))

    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
            


        
        super.prepareLayout()
        println("prepareLayout ...")

        calculateHeaders()

        
//        
//        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("prepareLayout ... done in \(stop - start) sec")
    }
    
}
