   }
   
   // MARK: animations
-  
   func foldingAnimation(_ timing: String, from: CGFloat, to: CGFloat, duration: TimeInterval, delay:TimeInterval, hidden:Bool) {
     
     let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.x")

  
  func createAnimationView() {
    
    let anAnimationView = UIView(frame: containerView.frame)
    anAnimationView.layer.cornerRadius = foregroundView.layer.cornerRadius
    anAnimationView.backgroundColor = .clear
    anAnimationView.translatesAutoresizingMaskIntoConstraints = false
    self.contentView.addSubview(anAnimationView)
    
    // copy constraints from containerView
    var newConstraints = [NSLayoutConstraint]()
    for constraint in self.contentView.constraints {
      if let item = constraint.firstItem as? UIView , item == containerView {
        let newConstraint = NSLayoutConstraint( item: anAnimationView, attribute: constraint.firstAttribute,
          relatedBy: constraint.relation, toItem: constraint.secondItem, attribute: constraint.secondAttribute,
          multiplier: constraint.multiplier, constant: constraint.constant)
        
        newConstraints.append(newConstraint)
      } else if let item: UIView = constraint.secondItem as? UIView , item == containerView {
        let newConstraint = NSLayoutConstraint(item: constraint.firstItem, attribute: constraint.firstAttribute,
          relatedBy: constraint.relation, toItem: anAnimationView, attribute: constraint.secondAttribute,
          multiplier: constraint.multiplier, constant: constraint.constant)
        
        newConstraints.append(newConstraint)

    
    let firstItemView = animationView.subviews.filter{$0.tag == 0}.first
    
    firstItemView?.layer.masksToBounds = true
    DispatchQueue.main.asyncAfter(deadline: .now() + durations[0], execute: {
      firstItemView?.layer.cornerRadius = 0
    })
    
    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: {
      self.animationView?.alpha = 0
      self.containerView.alpha  = 1
