Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-invertible-scroll-view

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-invertible-scroll-view - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

9

InvertibleScrollView.js
'use strict';
let React = require('react-native');
let {
import React, {
PropTypes,

@@ -9,6 +8,6 @@ ScrollView,

View,
} = React;
let ScrollableMixin = require('react-native-scrollable-mixin');
} from 'react-native';
import ScrollableMixin from 'react-native-scrollable-mixin';
let cloneReferencedElement = require('react-native-clone-referenced-element');
import cloneReferencedElement from 'react-clone-referenced-element';

@@ -15,0 +14,0 @@ type DefaultProps = {

{
"name": "react-native-invertible-scroll-view",
"version": "0.1.2",
"version": "0.2.0",
"description": "An invertible ScrollView for React Native",

@@ -23,5 +23,5 @@ "main": "InvertibleScrollView.js",

"dependencies": {
"react-native-clone-referenced-element": "^1.0.0",
"react-clone-referenced-element": "^1.0.1",
"react-native-scrollable-mixin": "^1.0.1"
}
}

@@ -21,18 +21,79 @@ # InvertibleScrollView [![Slack](http://slack.exponentjs.com/badge.svg)](http://slack.exponentjs.com)

```js
var React = require('react-native');
var InvertibleScrollView = require('react-native-invertible-scroll-view');
var {
import React from 'react-native';
let {
ListView,
Text,
TouchableHighlight,
View,
StyleSheet,
} = React;
import InvertibleScrollView from 'react-native-invertible-scroll-view';
// Inside of a component's render() method:
render() {
return (
<ListView
renderScrollComponent={props => <InvertibleScrollView {...props} inverted />}
dataSource={...}
renderRow={...}
/>
);
class InvertedScrollComponent extends React.Component {
constructor(props, context) {
super(props, context);
this._data = [];
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
}),
};
}
render() {
return (
<ListView
renderScrollComponent={props => <InvertibleScrollView {...props} inverted />}
dataSource={this.state.dataSource}
renderHeader={this._renderHeader.bind(this)}
renderRow={this._renderRow.bind(this)}
style={styles.container}
/>
);
}
_renderHeader() {
return (
<TouchableHighlight
onPress={this._onPress.bind(this)}
style={styles.button}>
<Text>Add a row</Text>
</TouchableHighlight>
);
},
_renderRow(row) {
return <Text key={row} style={styles.row}>{row}</Text>
},
_onPress() {
this._data.push(`${new Date}`);
var rows = this._data;
// It's important to keep row IDs consistent to avoid extra rendering. You
// may need to reverse the list of row IDs so the so that the inversion
// will order the rows correctly.
var rowIds = rows.map((row, index) => index).reverse();
this.setState({
dataSource: this.state.dataSource.cloneWithRows(rows, rowIds),
});
}
}
let styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
button: {
padding: 20,
borderStyle: 'solid',
borderWidth: 1,
borderColor: 'black',
},
row: {
padding: 4,
},
}
```

@@ -39,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc