Permalink
Browse files

Fix Keyboard avoiding View component

Reviewed By: ericvicenti

Differential Revision: D5059434

fbshipit-source-id: 3720aa8ee60ed7cc9fd6c3ab7efa38986b806302
  • Loading branch information...
Reem Helou authored and facebook-github-bot committed May 22, 2017
1 parent 341970d commit a975c1e834825d797391e00258acf2f7e1261ae7
Showing with 6 additions and 7 deletions.
  1. +6 −7 Libraries/Components/Keyboard/KeyboardAvoidingView.js
@@ -14,8 +14,8 @@
const Keyboard = require('Keyboard');
const LayoutAnimation = require('LayoutAnimation');
const Platform = require('Platform');
const React = require('React');
const PropTypes = require('prop-types');
const React = require('React');
const TimerMixin = require('react-timer-mixin');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');
@@ -93,12 +93,11 @@ const KeyboardAvoidingView = React.createClass({
return 0;
}
const y1 = Math.max(frame.y, keyboardFrame.screenY - this.props.keyboardVerticalOffset);
const y2 = Math.min(frame.y + frame.height, keyboardFrame.screenY + keyboardFrame.height - this.props.keyboardVerticalOffset);
if (frame.y > keyboardFrame.screenY) {
return frame.y + frame.height - keyboardFrame.screenY - this.props.keyboardVerticalOffset;
}
return Math.max(y2 - y1, 0);
const keyboardY = keyboardFrame.screenY - this.props.keyboardVerticalOffset;
// Calculate the displacement needed for the view such that it
// no longer overlaps with the keyboard
return Math.max(frame.y + frame.height - keyboardY, 0);
},
onKeyboardChange(event: ?KeyboardChangeEvent) {

0 comments on commit a975c1e

Please sign in to comment.