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

fixed button width for widescreens #307

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 15 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ var Swipeout = (0, _createReactClass2.default)({
disabled: false,
rowID: -1,
sectionID: -1,
sensitivity: 50
sensitivity: 50,
buttonWidth: 80
};
},

Expand Down Expand Up @@ -195,8 +196,8 @@ var Swipeout = (0, _createReactClass2.default)({
} else {
this._callOnClose();
}
this.refs.swipeoutContent.measure(function (ox, oy, width, height) {
var buttonWidth = _this2.props.buttonWidth || width / 5;
this.swipeoutContent.measure(function (ox, oy, width, height) {
var buttonWidth = _this2.props.buttonWidth;
_this2.setState({
btnWidth: buttonWidth,
btnsLeftWidth: _this2.props.left ? buttonWidth * _this2.props.left.length : 0,
Expand Down Expand Up @@ -337,8 +338,8 @@ var Swipeout = (0, _createReactClass2.default)({
_openRight: function _openRight() {
var _this3 = this;

this.refs.swipeoutContent.measure(function (ox, oy, width, height) {
var btnWidth = _this3.props.buttonWidth || width / 5;
this.swipeoutContent.measure(function (ox, oy, width, height) {
var btnWidth = _this3.props.buttonWidth;

_this3.setState({
btnWidth: btnWidth,
Expand All @@ -359,8 +360,8 @@ var Swipeout = (0, _createReactClass2.default)({
_openLeft: function _openLeft() {
var _this4 = this;

this.refs.swipeoutContent.measure(function (ox, oy, width, height) {
var btnWidth = _this4.props.buttonWidth || width / 5;
this.swipeoutContent.measure(function (ox, oy, width, height) {
var btnWidth = _this4.props.buttonWidth;

_this4.setState({
btnWidth: btnWidth,
Expand All @@ -379,6 +380,8 @@ var Swipeout = (0, _createReactClass2.default)({
},

render: function render() {
var _this5 = this;

var contentWidth = this.state.contentWidth;
var posX = this.getTweeningValue('contentPos');

Expand Down Expand Up @@ -427,7 +430,9 @@ var Swipeout = (0, _createReactClass2.default)({
_react2.default.createElement(
_reactNative.View,
_extends({
ref: 'swipeoutContent',
ref: function ref(node) {
return _this5.swipeoutContent = node;
},
style: styleContent,
onLayout: this._onLayout
}, this._panResponder.panHandlers),
Expand Down Expand Up @@ -462,7 +467,7 @@ var Swipeout = (0, _createReactClass2.default)({
},

_renderButton: function _renderButton(btn, i) {
var _this5 = this;
var _this6 = this;

return _react2.default.createElement(SwipeoutBtn, {
backgroundColor: btn.backgroundColor,
Expand All @@ -472,7 +477,7 @@ var Swipeout = (0, _createReactClass2.default)({
height: this.state.contentHeight,
key: i,
onPress: function onPress() {
return _this5._autoClose(btn);
return _this6._autoClose(btn);
},
text: btn.text,
type: btn.type,
Expand Down
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const Swipeout = createReactClass({
rowID: -1,
sectionID: -1,
sensitivity: 50,
buttonWidth: 80,
};
},

Expand Down Expand Up @@ -168,7 +169,7 @@ const Swipeout = createReactClass({
this._callOnClose();
}
this.swipeoutContent.measure((ox, oy, width, height) => {
let buttonWidth = this.props.buttonWidth || (width / 5);
let buttonWidth = this.props.buttonWidth;
this.setState({
btnWidth: buttonWidth,
btnsLeftWidth: this.props.left ? buttonWidth * this.props.left.length : 0,
Expand Down Expand Up @@ -303,7 +304,7 @@ const Swipeout = createReactClass({

_openRight: function () {
this.swipeoutContent.measure((ox, oy, width, height) => {
let btnWidth = this.props.buttonWidth || (width / 5);
let btnWidth = this.props.buttonWidth;

this.setState({
btnWidth,
Expand All @@ -323,7 +324,7 @@ const Swipeout = createReactClass({

_openLeft: function () {
this.swipeoutContent.measure((ox, oy, width, height) => {
let btnWidth = this.props.buttonWidth || (width / 5);
let btnWidth = this.props.buttonWidth;

this.setState({
btnWidth,
Expand Down