         
         // Define values
         // Get current layer values
-        let mask = self.layer.mask?.presentationLayer() as? CAGradientLayer
+        let mask = maskLayer?.presentationLayer() as? CAGradientLayer
         let currentValues = mask?.colors as? [CGColorRef]
         
         switch (type) {

            }()
            
            // Apply scrolling animation
            self.layer.mask?.addAnimation(gradientAnimation!, forKey: "gradient")
        }
        
        let completion = CompletionBlock<MLAnimationCompletion>({ (finished: Bool) -> () in

    
    private func applyGradientMask(fadeLength: CGFloat, animated: Bool) {
        // Remove any in-flight animations
        maskLayer?.removeAllAnimations()
        
        // Check for zero-length fade
        if (fadeLength <= 0.0) {
