1.7.0 • Published 4 years ago

react-native-spacer v1.7.0

Weekly downloads
116
License
MIT
Repository
github
Last release
4 years ago

Technically, it uses Animated.View and will animate a translateY value to avoid the keyboard. KeyboardAvodingView is highly recommended. But in some rare case when KeyboardAvodingView not working, try this Spacer.

Demo

See demo on Expo Snack

I. Installation

npm install --save react-native-spacer

II. How to use

Class Spacer is a wrapper using Animated.View. For usage, see official documentation Animated and View

1. Import library

import Spacer from 'react-native-spacer';

2. Wrap component into Spacer

<Spacer spaceMargin={20}>
    {/* Components that need to float when keyboard showing */}
</Spacer>

III. Properties

Property NameTypeDefault ValueDefinition
spaceMarginnumber0Component's margin above the keyboard when it displayed
enabledbooltrueSet to false to disable Spacer
backgroundColorstring#fffffff7Spacer component background color
animationDurationnumber300Duration of the view animation

Feel free to have any question, file an issue, or contributing to the module.

IV. Todo

  • Create tests

V. Changes

  • v1.7: Fix measureInWindow not found for latest RN version (thanks @kristerkari)