diff --git a/Example/LazyloadListExample.js b/Example/LazyloadListExample.js
index af6df7b..617aa16 100644
--- a/Example/LazyloadListExample.js
+++ b/Example/LazyloadListExample.js
@@ -1,137 +1,143 @@
-import React, {
- Component
-} from 'react';
+import React, { Component } from "react";
-import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- ListView
-} from 'react-native';
+import { AppRegistry, StyleSheet, Text, View } from "react-native";
+import ListView from "deprecated-react-native-listview";
+import { LazyloadListView, LazyloadView } from "react-native-lazyload";
-import {
- LazyloadListView,
- LazyloadView
-} from 'react-native-lazyload';
-
-import data from './MOCK_DATA.json';
+import data from "./MOCK_DATA.json";
class LazyloadListExample extends Component {
constructor() {
super(...arguments);
- let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
+ let ds = new ListView.DataSource({
+ rowHasChanged: (r1, r2) => r1 !== r2,
+ });
this.state = {
- dataSource: ds.cloneWithRows(data)
+ dataSource: ds.cloneWithRows(data),
};
}
- renderRow = (file) => {
- return
-
-
- {file.id}
-
-
- {file.first_name} {file.last_name}
- email: {file.email}
- last visit ip: {file.ip_address}
-
-
- {file.gender}
-
-
- ;
+ renderRow = file => {
+ return (
+
+
+
+ {file.id}
+
+
+
+ {file.first_name} {file.last_name}
+
+
+ email:
+ {file.email}
+
+
+ last visit ip:
+ {file.ip_address}
+
+
+
+
+ {file.gender}
+
+
+
+
+ );
};
render() {
- return ;
+ return (
+
+ );
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
- backgroundColor: '#F5FCFF'
+ backgroundColor: "#F5FCFF",
},
content: {
paddingTop: 20,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center",
},
view: {
height: 70,
width: 320,
paddingVertical: 5,
borderBottomWidth: StyleSheet.hairlineWidth,
- borderBottomColor: '#666'
+ borderBottomColor: "#666",
},
file: {
width: 320,
flex: 1,
- flexDirection: 'row'
+ flexDirection: "row",
},
id: {
width: 50,
- alignItems: 'center',
- justifyContent: 'center'
+ alignItems: "center",
+ justifyContent: "center",
},
idText: {
- fontSize: 10
+ fontSize: 10,
},
detail: {
- justifyContent: 'space-around',
- flex: 1
+ justifyContent: "space-around",
+ flex: 1,
},
name: {
- textAlign: 'center',
+ textAlign: "center",
lineHeight: 15,
- color: '#666',
- marginBottom: 5
+ color: "#666",
+ marginBottom: 5,
},
email: {
fontSize: 10,
- color: 'blue',
- textDecorationColor: 'blue',
- textDecorationLine: 'underline',
- textDecorationStyle: 'solid'
+ color: "blue",
+ textDecorationColor: "blue",
+ textDecorationLine: "underline",
+ textDecorationStyle: "solid",
},
ip: {
fontSize: 12,
- color: 'grey'
+ color: "grey",
},
gender: {
width: 50,
- alignItems: 'center',
- justifyContent: 'center'
+ alignItems: "center",
+ justifyContent: "center",
},
genderText: {
- fontSize: 10
+ fontSize: 10,
},
title: {
- color: '#333',
- fontSize: 12
+ color: "#333",
+ fontSize: 12,
},
male: {
- color: 'skyblue'
+ color: "skyblue",
},
female: {
- color: 'pink'
- }
+ color: "pink",
+ },
});
export default LazyloadListExample;
diff --git a/lib/Anim.js b/lib/Anim.js
index 99c570d..5ad05b6 100644
--- a/lib/Anim.js
+++ b/lib/Anim.js
@@ -1,6 +1,5 @@
-import React, {
- PropTypes
-} from 'react';
+import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import ReactNative, {
LayoutAnimation
} from 'react-native';
diff --git a/lib/LazyloadChild.js b/lib/LazyloadChild.js
index 4a85374..070587f 100644
--- a/lib/LazyloadChild.js
+++ b/lib/LazyloadChild.js
@@ -1,31 +1,43 @@
-export default class {
+export default class LazyloadChild {
constructor(container, measureLayout, toggle) {
- let {offset, recycle, horizontal, contentOffset, dimensions} = container;
+ let {
+ offset,
+ recycle,
+ horizontal,
+ contentOffset,
+ dimensions,
+ } = container;
this._recycle = recycle;
this._toggle = toggle;
this._horizontal = horizontal;
if (recycle && offset >= recycle) {
- console.warn('Recycle distance should be much more than render distance.');
+ console.warn(
+ "Recycle distance should be much more than render distance."
+ );
recycle = offset;
}
measureLayout(container.data, (x, y, width, height) => {
- let {width: sightWidth, height: sightHeight} = dimensions;
- this._sight = horizontal ? {
- start: -(sightWidth - x + offset),
- end: x + width + offset
- } : {
- start: -(sightHeight - y + offset),
- end: y + height + offset
- };
+ let { width: sightWidth, height: sightHeight } = dimensions;
+ this._sight = horizontal
+ ? {
+ start: -(sightWidth - x + offset),
+ end: x + width + offset,
+ }
+ : {
+ start: -(sightHeight - y + offset),
+ end: y + height + offset,
+ };
if (recycle) {
- this._bound = horizontal ? {
- start: -(recycle + sightWidth - x),
- end: x + width + recycle
- } : {
- start: -(recycle + sightHeight - y),
- end: y + height + recycle
- };
+ this._bound = horizontal
+ ? {
+ start: -(recycle + sightWidth - x),
+ end: x + width + recycle,
+ }
+ : {
+ start: -(recycle + sightHeight - y),
+ end: y + height + recycle,
+ };
}
this.move(contentOffset.x, contentOffset.y);
@@ -49,11 +61,21 @@ export default class {
let recycle = this._recycle;
let scrolled = this._horizontal ? x : y;
- if (this._recycled && scrolled >= bound.start && scrolled <= bound.end) { // Recycled element back into recycle distance
+ if (
+ this._recycled &&
+ scrolled >= bound.start &&
+ scrolled <= bound.end
+ ) {
+ // Recycled element back into recycle distance
this._recycled = false;
this._visible = true;
this._toggle(true);
- } else if (!this._visible && scrolled >= sight.start && scrolled <= sight.end) { // Invisible element scroll into sight
+ } else if (
+ !this._visible &&
+ scrolled >= sight.start &&
+ scrolled <= sight.end
+ ) {
+ // Invisible element scroll into sight
this._visible = true;
this._toggle(true);
} else if (this._visible && recycle && !this._recycled) {
diff --git a/lib/LazyloadImage.js b/lib/LazyloadImage.js
index 8c751d1..2047c9b 100644
--- a/lib/LazyloadImage.js
+++ b/lib/LazyloadImage.js
@@ -1,7 +1,7 @@
import React, {
Component,
- PropTypes
} from 'react';
+import PropTypes from 'prop-types';
import {
Image,
Platform
diff --git a/lib/LazyloadListView.js b/lib/LazyloadListView.js
index e14d20f..9eb8174 100644
--- a/lib/LazyloadListView.js
+++ b/lib/LazyloadListView.js
@@ -1,27 +1,23 @@
-import React, {
- Component,
- PropTypes
-} from 'react';
-import {
- ListView
-} from 'react-native';
-import ScrollableMixin from 'react-native-scrollable-mixin';
-import LazyloadScrollView from './LazyloadScrollView';
-
-class LazyloadListView extends Component{
- static displayName = 'LazyloadListView';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import ListView from "deprecated-react-native-listview";
+import ScrollableMixin from "react-native-scrollable-mixin";
+import LazyloadScrollView from "./LazyloadScrollView";
+
+class LazyloadListView extends Component {
+ static displayName = "LazyloadListView";
static propTypes = {
- ...ListView.propTypes
+ ...ListView.propTypes,
};
- refresh () {
+ refresh() {
this._scrollView.refresh();
}
get scrollProperties() {
return this._listView.scrollProperties;
- };
+ }
/**
* IMPORTANT: You must return the scroll responder of the underlying
@@ -36,14 +32,17 @@ class LazyloadListView extends Component{
}
render() {
- return this.props.name ? }
- ref={ele => this._listView = ele}
- /> : this._listView = ele}
- />;
+ return this.props.name ? (
+ (
+
+ )}
+ ref={ele => (this._listView = ele)}
+ />
+ ) : (
+ (this._listView = ele)} />
+ );
}
}
diff --git a/lib/LazyloadScrollView.js b/lib/LazyloadScrollView.js
index 681b3ba..3ccec88 100644
--- a/lib/LazyloadScrollView.js
+++ b/lib/LazyloadScrollView.js
@@ -1,7 +1,7 @@
import React, {
Component,
- PropTypes
} from 'react';
+import PropTypes from 'prop-types';
import ReactNative, {
ScrollView,
Dimensions
diff --git a/lib/LazyloadView.js b/lib/LazyloadView.js
index 6ef57bc..903a66e 100644
--- a/lib/LazyloadView.js
+++ b/lib/LazyloadView.js
@@ -1,7 +1,7 @@
import React, {
Component,
- PropTypes
} from 'react';
+import PropTypes from 'prop-types';
import {
View,
LayoutAnimation
diff --git a/package.json b/package.json
index 59086ad..248633f 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"url": "https://github.com/magicismight/react-native-lazyload"
},
"dependencies": {
+ "deprecated-react-native-listview": "0.0.5",
"react-native-scrollable-mixin": "^1.0.1"
},
"keywords": [