Skip to content

Commit

Permalink
Removed the longPressSensitivity and fixed PanResponder single touches
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Brandon Farrell committed Feb 3, 2019
1 parent da49dda commit 3ce9512
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
## 3.2.0 (January 2019)

- Removed the `longPressSensitivity` property as it did not work as intended and caused complications with swapping.
- Fixed the PanResponder to respond to single touches by changing the `onStartShouldSetPanResponder` and `onStartShouldSetPanResponderCapture` to return true.
- Fixed the peer-dependencies warning.
- Documented the cause of [issue #12](https://github.com/lukebrandonfarrell/react-native-images-collage/issues/12).

## 3.1.8 (January 2019)

- Removed the `<TouchableWithoutFeedback />` which wraps each image to enable a long press and replaced it with a custom PanResponder long press timer.
Expand Down
6 changes: 1 addition & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "react-native-images-collage",
"version": "3.1.8",
"version": "3.2.0",
"description": "Customizable image grid component for React Native",
"keywords": [
"react-native",
Expand All @@ -23,10 +23,6 @@
"flow": "flow",
"build": "flow-remove-types src/ -d lib/"
},
"peerDependencies": {
"react": "^16.1.0",
"react-native": "^0.54.0"
},
"author": "Luke Brandon Farrell",
"license": "MIT",
"readme": "README.md"
Expand Down
11 changes: 2 additions & 9 deletions src/CollageImage.js
Expand Up @@ -56,8 +56,8 @@ class CollageImage extends React.Component {
this.deltaScaling = 0;

this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => false,
onStartShouldSetPanResponderCapture: (evt, gestureState) => false,
onStartShouldSetPanResponder: (evt, gestureState) => true,
onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
onMoveShouldSetPanResponder: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
onPanResponderGrant: (e, gestureState) => {
Expand Down Expand Up @@ -124,12 +124,6 @@ class CollageImage extends React.Component {
const newPanningX = (panningX - incrementX);
const newPanningY = (panningY - incrementY);

// Clear long press timer if we are panning significantly
if(Math.abs(incrementX) > props.longPressSensitivity ||
Math.abs(incrementY) > props.longPressSensitivity) {
if (this.onLongPressTimeout) clearTimeout(this.onLongPressTimeout);
}

this.setState({ panningX: newPanningX, panningY: newPanningY });

// DELTA PANNING
Expand Down Expand Up @@ -400,7 +394,6 @@ CollageImage.propTypes = {
scaleAmplifier: PropTypes.number.isRequired, // ADJUST SCALING
retainScaleOnSwap: PropTypes.bool,
longPressDelay: PropTypes.number,
longPressSensitivity: PropTypes.number,
};

export default CollageImage;
5 changes: 1 addition & 4 deletions src/DynamicCollage.js
Expand Up @@ -16,7 +16,7 @@ class DynamicCollage extends React.Component {
}

renderMatrix(){
const { matrix, direction, retainScaleOnSwap, longPressDelay, longPressSensitivity } = this.props;
const { matrix, direction, retainScaleOnSwap, longPressDelay } = this.props;

const sectionDirection = (direction === 'row') ? 'column' : 'row';
const reducer = (accumulator, currentValue) => accumulator + currentValue;
Expand Down Expand Up @@ -48,7 +48,6 @@ class DynamicCollage extends React.Component {
scaleAmplifier={this.props.scaleAmplifier}
retainScaleOnSwap={retainScaleOnSwap}
longPressDelay={longPressDelay}
longPressSensitivity={longPressSensitivity}
matrix={matrix}
/>
);
Expand Down Expand Up @@ -234,7 +233,6 @@ DynamicCollage.defaultProps = {
scaleAmplifier: 1.0, // ADJUST SCALING
retainScaleOnSwap: true,
longPressDelay: 500,
longPressSensitivity: 4.5,

// STYLE --------------
containerStyle: {
Expand Down Expand Up @@ -276,7 +274,6 @@ DynamicCollage.propTypes = {
scaleAmplifier: PropTypes.number, // ADJUST SCALING
retainScaleOnSwap: PropTypes.bool,
longPressDelay: PropTypes.number,
longPressSensitivity: PropTypes.number,
};

export { DynamicCollage };

0 comments on commit 3ce9512

Please sign in to comment.