Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sortable/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let {
Text,
TouchableHighlight,
View,
UIManager,
} = require('react-native');


Expand Down Expand Up @@ -88,9 +89,10 @@ let RowComponent = React.createClass({

let MyComponent = React.createClass({
render: function() {
UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
return (
<View style={styles.container}>
<View style={{height: 64, backgroundColor: 'lightblue'} /* fake nav bar */} >
<View style={{height: 89, backgroundColor: 'lightblue'} /* fake nav bar */} >
<Text style={styles.welcome} > Sortable </Text>
</View>
<SortableListView
Expand Down
22 changes: 17 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ListView,
Dimensions,
PanResponder,
Platform,
LayoutAnimation,
InteractionManager,
} from 'react-native'
Expand All @@ -28,6 +29,7 @@ class Row extends React.Component {
}

handlePress = e => {
e.persist(); // suppresses an RN warning on Row press
if (!this.refs.view) return
this.refs.view.measure(
(frameX, frameY, frameWidth, frameHeight, pageX, pageY) => {
Expand Down Expand Up @@ -187,7 +189,11 @@ class SortableListView extends React.Component {
this.moveY = layout.pageY + layout.frameHeight / 2 + gestureState.dy
this.direction = gestureState.dy >= this.dy ? 'down' : 'up'
this.dy = gestureState.dy
onPanResponderMoveCb(e, gestureState)
const adjustedListHeight = HEIGHT - this.listLayout.height;
if (gestureState.moveY > adjustedListHeight)
{
onPanResponderMoveCb(e, gestureState)
}
},

onPanResponderGrant: () => {
Expand Down Expand Up @@ -375,8 +381,11 @@ class SortableListView extends React.Component {
if (!isLast) i--

if (String(i) !== this.state.hovering && i >= 0) {
// LayoutAnimation is not supported in react-native-web
LayoutAnimation && LayoutAnimation.easeInEaseOut()
if (Platform.OS === 'ios') {
// TODO: Fix for Android and Windows https://github.com/facebook/react-native/issues/13207
// LayoutAnimation is not supported in react-native-web
LayoutAnimation && LayoutAnimation.easeInEaseOut()
}
this._previouslyHovering = this.state.hovering
this.__activeY = this.panY
this.setState({
Expand All @@ -388,8 +397,11 @@ class SortableListView extends React.Component {
handleRowActive = row => {
if (this.props.disableSorting) return
this.state.pan.setValue({ x: 0, y: 0 })
// LayoutAnimation is not supported in react-native-web
LayoutAnimation && LayoutAnimation.easeInEaseOut()
if (Platform.OS === 'ios') {
// TODO: Fix for Android and Windows https://github.com/facebook/react-native/issues/13207
// LayoutAnimation is not supported in react-native-web
LayoutAnimation && LayoutAnimation.easeInEaseOut()
}
this.moveY = row.layout.pageY + row.layout.frameHeight / 2
this.setState(
{
Expand Down