Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

feat: enableScroll props #295

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ scroll | func | Yes | | prevent parent scroll
style | style | Yes | | style of the container
sensitivity | number | Yes | 50 | change the sensitivity of gesture
buttonWidth | number | Yes | | each button width
enableScroll | bool | Yes | true | if false, the component won't slide horizontally with the button

##### Button props

Expand Down
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,17 @@ var Swipeout = (0, _createReactClass2.default)({
style: (_reactNative.ViewPropTypes || _reactNative.View.propTypes).style,
sensitivity: _propTypes2.default.number,
buttonWidth: _propTypes2.default.number,
disabled: _propTypes2.default.bool
disabled: _propTypes2.default.bool,
enableScroll: _propTypes2.default.bool
},

getDefaultProps: function getDefaultProps() {
return {
disabled: false,
rowID: -1,
sectionID: -1,
sensitivity: 50
sensitivity: 50,
enableScroll: true
};
},

Expand Down Expand Up @@ -279,6 +281,9 @@ var Swipeout = (0, _createReactClass2.default)({
},

_rubberBandEasing: function _rubberBandEasing(value, limit) {
if (!this.props.enableScroll) {
return 0;
}
if (value < 0 && value < limit) return limit - Math.pow(limit - value, 0.85);else if (value > 0 && value > limit) return limit + Math.pow(value - limit, 0.85);
return value;
},
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const Swipeout = createReactClass({
sensitivity: PropTypes.number,
buttonWidth: PropTypes.number,
disabled: PropTypes.bool,
enableScroll: PropTypes.bool
},

getDefaultProps: function () {
Expand All @@ -118,6 +119,7 @@ const Swipeout = createReactClass({
rowID: -1,
sectionID: -1,
sensitivity: 50,
enableScroll: true
};
},

Expand Down Expand Up @@ -253,6 +255,9 @@ const Swipeout = createReactClass({
},

_rubberBandEasing: function (value, limit) {
if(!this.props.enableScroll){
return 0;
}
if (value < 0 && value < limit) return limit - Math.pow(limit - value, 0.85);
else if (value > 0 && value > limit) return limit + Math.pow(value - limit, 0.85);
return value;
Expand Down