@momo-kits/swipe 0.0.62-alpha.13 → 0.0.62-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/SwipeAction.js +23 -8
  2. package/Swiper.js +731 -663
  3. package/package.json +2 -2
package/SwipeAction.js CHANGED
@@ -30,6 +30,7 @@ const MAX_VELOCITY_CONTRIBUTION = 5;
30
30
  const SCROLL_LOCK_MILLISECONDS = 300;
31
31
  const SCREEN_WIDTH = Dimensions.get('window').width;
32
32
  const WIDTH_HIDDEN_RIGHT = 190;
33
+
33
34
  class SwipeAction extends Component {
34
35
  constructor(props) {
35
36
  super(props);
@@ -52,13 +53,13 @@ class SwipeAction extends Component {
52
53
  isRightActionVisible: false,
53
54
  leftOpenValue: 0,
54
55
  rightOpenValue: 0,
56
+ stopLeftSwipe: SCREEN_WIDTH,
57
+ stopRightSwipe: -SCREEN_WIDTH,
55
58
  };
56
59
  const { leftAction, rightAction } = this.props;
57
60
  const buttonCellWidth = WIDTH_HIDDEN_RIGHT / 2;
58
61
  // leftAction ? this.leftOpenValue = leftAction.length * buttonCellWidth : 0;
59
62
  // rightAction ? this.rightOpenValue = -rightAction.length * buttonCellWidth : 0;
60
- this.stopLeftSwipe = SCREEN_WIDTH;
61
- this.stopRightSwipe = -SCREEN_WIDTH;
62
63
  this._translateX = new Animated.Value(0);
63
64
  if (this.props.onSwipeValueChange) {
64
65
  this._translateX.addListener(({ value }) => {
@@ -251,11 +252,14 @@ class SwipeAction extends Component {
251
252
  newDX = 0;
252
253
  }
253
254
 
254
- if (this.stopLeftSwipe && newDX > this.stopLeftSwipe) {
255
- newDX = this.stopLeftSwipe;
255
+ if (this.state.stopLeftSwipe && newDX > this.state.stopLeftSwipe) {
256
+ newDX = this.state.stopLeftSwipe;
256
257
  }
257
- if (this.stopRightSwipe && newDX < this.stopRightSwipe) {
258
- newDX = this.stopRightSwipe;
258
+ if (
259
+ this.state.stopRightSwipe &&
260
+ newDX < this.state.stopRightSwipe
261
+ ) {
262
+ newDX = this.state.stopRightSwipe;
259
263
  }
260
264
 
261
265
  // set action buttons visibility
@@ -476,12 +480,14 @@ class SwipeAction extends Component {
476
480
  onLeftActionLayout = ({ nativeEvent }) => {
477
481
  this.setState({
478
482
  leftOpenValue: nativeEvent.layout.width,
483
+ stopLeftSwipe: nativeEvent.layout.width,
479
484
  });
480
485
  };
481
486
 
482
487
  onRightActionLayout = ({ nativeEvent }) => {
483
488
  this.setState({
484
489
  rightOpenValue: -nativeEvent.layout.width,
490
+ stopRightSwipe: -nativeEvent.layout.width,
485
491
  });
486
492
  };
487
493
 
@@ -492,6 +498,7 @@ class SwipeAction extends Component {
492
498
  ...styles.standaloneRowBack,
493
499
  ...{ backgroundColor: actionBackground },
494
500
  };
501
+ console.log(this.state.stopLeftSwipe);
495
502
  return (
496
503
  <View style={hiddenRowStyle}>
497
504
  {this.state.isLeftActionVisible && (
@@ -554,7 +561,11 @@ class SwipeAction extends Component {
554
561
  if (renderRightAction) {
555
562
  return (
556
563
  <View key={item + index}>
557
- {renderRightAction({ item, index, rowIndex })}
564
+ {renderRightAction({
565
+ item,
566
+ index,
567
+ rowIndex,
568
+ })}
558
569
  </View>
559
570
  );
560
571
  }
@@ -580,7 +591,11 @@ class SwipeAction extends Component {
580
591
  if (renderLeftAction) {
581
592
  return (
582
593
  <View key={item + index}>
583
- {renderLeftAction({ item, index, rowIndex })}
594
+ {renderLeftAction({
595
+ item,
596
+ index,
597
+ rowIndex,
598
+ })}
584
599
  </View>
585
600
  );
586
601
  }