     private weak var layoutBarTop:NSLayoutConstraint!
     private weak var layoutCollectionLeft:NSLayoutConstraint!
     private weak var layoutControlsWidth:NSLayoutConstraint!
+    private var drag:Drag
     private let kBarHeight:CGFloat = 210
+    private let kControlsMinThreshold:CGFloat = 7
+    private let kControlsExtraThreshold:CGFloat = 30
+    private let kControlsMenuThreshold:CGFloat = 50
+    private let kControlsMaxThreshold:CGFloat = 180
+    private let kExtraSpeed:CGFloat = 3
     private let kDeselectTime:TimeInterval = 0.2
+    private let kAnimationDuration:TimeInterval = 0.3
     
     override init(controller:CController)
     {
+        drag = Drag.stand
+        
         super.init(controller:controller)
         self.controller = controller as? CLinearEquationsProject
         

        return item
    }
    
    //MARK: public
    
    func refresh()
    {
        spinner.stopAnimating()
        collectionView.isHidden = false
        collectionView.reloadData()

        }
        
        layoutBarTop.constant = offsetY
        
        switch drag
        {
        case Drag.stand:
            
            let offsetX:CGFloat = -scrollView.contentOffset.x
            let controlsWidth:CGFloat
            
            if offsetX < 0
            {
                controlsWidth = 0
            }
            else
            {
                let extraDelta:CGFloat = offsetX - kControlsExtraThreshold
                let extraWidth:CGFloat
                
                if extraDelta > 0
                {
                    extraWidth = kExtraSpeed * extraDelta
                }
                else
                {
                    extraWidth = 0
                }
                
                controlsWidth = offsetX + extraWidth
            }
            
            layoutControlsWidth.constant = controlsWidth
            
            break
            
        case Drag.restart:
            
            restartingScroll()
            
            break
            
        case Drag.avoid:
            break
        }
    }
    
    func scrollViewDidEndDecelerating(_ scrollView:UIScrollView)
    {
        switch drag
        {
        case Drag.restart:
            
            drag = Drag.stand
            
            break
            
        case Drag.avoid:
            
            drag = Drag.restart
            
            break
            
        default:
            
            break
        }
    }
    
    func scrollViewDidEndDragging(_ scrollView:UIScrollView, willDecelerate decelerate:Bool)
    {
        let controlsWidth:CGFloat = layoutControlsWidth.constant
        
        if controlsWidth > kControlsMinThreshold
        {
            drag = Drag.avoid
            
            let newControlsWidth:CGFloat
            
            if controlsWidth > kControlsMenuThreshold
            {
                newControlsWidth = kControlsMaxThreshold
            }
            else
            {
                newControlsWidth = kControlsMenuThreshold
            }
            
            layoutControlsWidth.constant = newControlsWidth
            layoutCollectionLeft.constant = newControlsWidth
            
            UIView.animate(
                withDuration:kAnimationDuration)
            { [weak self] in
                
                self?.layoutIfNeeded()
            }
        }
        else
        {
            drag = Drag.stand
        }
    }
    
    func numberOfSections(in collectionView:UICollectionView) -> Int
