     private var isAnimating = false
     private var isSwipingToDismiss = false
     private var dynamicTransparencyActive = false
-    
+    private var initialCloseButtonFrame = CGRectZero
+
     private let showDuration               = 0.25
     private let dismissDuration            = 0.25
     private let showCloseButtonDuration    = 0.2

        
        if (self.dynamicTransparencyActive == true && keyPath == "contentOffset") {
            
            let distanceToEdge = (self.scrollView.bounds.height / 2) + (self.imageView.bounds.height / 2)
            
            self.overlayView.alpha = 1 - fabs(self.scrollView.contentOffset.y / distanceToEdge)
            self.closeButton.alpha = 1 - fabs(self.scrollView.contentOffset.y / distanceToEdge) * 10   //a multiplier makes the effect on transparency kick in much faster. 10 in this case works well.
        }
    }
    

        self.closeButton.setBackgroundImage(closeButtonAssets.normalImage, forState: UIControlState.Normal)
        self.closeButton.setBackgroundImage(closeButtonAssets.highlightedImage, forState: UIControlState.Highlighted)
        self.closeButton.alpha = 0.0
        self.initialCloseButtonFrame = self.closeButton.frame
    }
    
    private func configureGestureRecognizers() {
