         } else if isKeyboardWillHide(notification) {
             // Animated to restore to original state
             UIView.animate(withDuration: keyboardDismissingDuration(notification), animations: { () -> Void in
+                self._isChangingContentInset = true
                 self.contentInset = self.originalContentInset ?? UIEdgeInsets.zero
+                self._isChangingContentInset = false
+
+                self._isChangingContentOffset = true
                 self.contentOffset = self.originalContentOffset ?? CGPoint.zero
+                self._isChangingContentOffset = false
                 }, completion: { (completed) -> Void in
                     self.keyboardFrame = nil
             })

	
    private var contentViewEqualWidthConstraint: NSLayoutConstraint!
    private var contentViewEqualHeightConstraint: NSLayoutConstraint!
	
    // These two values are used to backup original states
    private var originalContentInset: UIEdgeInsets!
    private var originalContentOffset: CGPoint!
    
    // Keep values from UIKeyboardNotification
    private var keyboardFrame: CGRect!
    private var keyboardAnimationDuration: TimeInterval!

            
            // Animated change self.contentInset
            UIView.animate(withDuration: keyboardAnimationDuration, animations: { () -> Void in
                self._isChangingContentInset = true
                self.contentInset = UIEdgeInsets(top: self.contentInset.top, left: self.contentInset.left, bottom: cutHeight, right: self.contentInset.right)
                self._isChangingContentInset = false
            }, completion: nil)
        }
		
        // Enlarge the targetFrame, give top and bottom some points margin
