Skip to content

Instantly share code, notes, and snippets.

@xxjinwei
Created May 10, 2017 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xxjinwei/8aa6b9a219e650c5011ce90159d7ac3a to your computer and use it in GitHub Desktop.
Save xxjinwei/8aa6b9a219e650c5011ce90159d7ac3a to your computer and use it in GitHub Desktop.
get keyboard height
import { Keyboard, Dimensions } from 'react'
let KEYBOARD_HEIGHT = 0
Keyboard.addListener('keyboardDidChangeFrame', function ({ endCoordinates }) {
KEYBOARD_HEIGHT = DIMENSION.height - endCoordinates.screenY
})
@xxjinwei
Copy link
Author

// https://github.com/Andr3wHur5t/react-native-keyboard-spacer/blob/master/KeyboardSpacer.js#L59
const updateListener = Platform.OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow'
const resetListener = Platform.OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment