npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-input-scroll-view

v1.11.0

Published

Perfect TextInput ScrollView

Downloads

14,317

Readme

react-native-input-scroll-view npm version

Mainly to achieve the following functions:

  • When the keyboard pops up, the TextInput will automatically adjust to the top of the keyboard.
  • When the keyboard pops up, the content of the ScrollView will not be obscured by the keyboard.
  • When multiline TextInput gets focus, the selected cursor will be automatically adjusted to the top of the keyboard.
  • When the multiline TextInput create new line, the new line will automatically adjust to the top of the keyboard.
  • Put your finger on top of TextInput and slide ScrollView, when you lift your finger, the TextInput will not get focus.

    

Installation

npm

$ npm install react-native-input-scroll-view --save

yarn

$ yarn add react-native-input-scroll-view

Usage

import InputScrollView from 'react-native-input-scroll-view';
...
state = {
    text: '',
};

render() {
    const { text } = this.state;
    return (
        <InputScrollView>
            <TextInput />
            <TextInput />
            <TextInput value={text}
                       onChangeText={text => this.setState({ text })}
                       multiline />
      	</InputScrollView>
    );
}

React-native-input-scroll-view automatically modify onContentSizeChange, onSelectionChange, and onChange TextInput props. It is not yet designed to pass them down if the TextInput is wrapped into another component so don’t forget to do it:

import InputScrollView from 'react-native-input-scroll-view';
...

const MyComponent = props => (
    <View>
        <TextInput {...props} />
    </View>
);
...

state = {
    text: '',
};

render() {
    const { text } = this.state;
    return (
        <InputScrollView>
            <MyComponent value={text}
                         onChangeText={text => this.setState({ text })}
                        />
      	</InputScrollView>
    );
}

Note that if the cursor is to be correctly adjusted to the top of the keyboard, you must bind value to TextInput.

Multiline TextInput in the Android

If your ReactNative version is on or above v0.57, skip this section.

Before a certain version of ReactNative, multiline TextInput height on an Android device could not change properly based on its content, so we need to add additional processing code

import InputScrollView from 'react-native-input-scroll-view';
...

state = {
    text: '',
    textareaHeight: null,
};

render() {
    const { text, textareaHeight } = this.state;
    return (
        <InputScrollView>
            <TextInput />
            <TextInput />
            <TextInput style={{ height: textareaHeight }}
                       value={text}
                       onChangeText={text => this.setState({ text })}
                       onContentSizeChange={this._onContentSizeChange}
                       multiline />
      	</InputScrollView>
    );
}

_onContentSizeChange = ({nativeEvent:event}) => {
    this.setState({ textareaHeight: event.contentSize.height });
};

Props

| Property | Type | Default | Description | | ----------------------- | -------- | ------- | ---------------------------------------- | | topOffset | number | undefined | The offset of the InputScrollView relative to the top of the window. When the screen contains TopBar, it is usually set to the height of TopBar. If not explicitly set, the program will automatically determine, but may cause problems. issues#43。 | | keyboardOffset | number | 40 | When automatic adjustment, the cursor relative to the top of the keyboard offset. | | multilineInputStyle | Style | null | If your multiline TextInput has a specific style, to ensure that the cursor can be accurately adjusted to the top of the keyboard, this is set as a multiline TextInput style, The style attributes that mainly include fontSizefontFamilylineHeight etc. affect the position of the cursor. Be careful not to include width and height. | | useAnimatedScrollView | bool | false | Replace regular ScrollView component with Animated.ScrollView component. | | supportHardwareKeyboard | bool | false | beta If your device does not use a soft keyboard, try using this parameter to solve the problem. issues#69 | | keyboardAvoidingViewProps | props | null | KeyboardAvoidingView component Props. Check them here: https://facebook.github.io/react-native/docs/keyboardavoidingview | | ...ScrollView.props | props | | All props from ScrollView are inherited. Check them here: https://facebook.github.io/react-native/docs/scrollview.html |

ENV

"react": "^16.0.0-alpha.12"
"react-native": ">=0.46.0"

Product case

App_Store

License

MIT