octopitus / rn-sliding-up-panel

Draggable sliding up panel implemented in React Native https://octopitus.github.io/rn-sliding-up-panel/
MIT License
928 stars 157 forks source link

onDragEnd does not always fire. #142

Closed pfrantz closed 5 years ago

pfrantz commented 5 years ago

Issue Description

Sometimes the onDragEnd does not fire. This seems to occur when you are nearing the top or bottom of the dragable range. There is a function called _isInsideDraggableRange which is causing the onDragEnd to be skipped if the animated value is either the top or bottom of the range. This is the due to the comparison being either > bottom or < top instead of >= bottom and <= top.

The drag problem can be fixed by amending the _isInsideDraggableRnge to the following:-

  _isInsideDraggableRange(value, gestureState) {
    const {top, bottom} = this.props.draggableRange

    if (gestureState.dy > 0) {
      return value => bottom
    }

    return value <= top
  }

Environment

octopitus commented 5 years ago

Thanks for pointing out @pfrantz. I've just provided the fix in v2.3.2.

pfrantz commented 5 years ago

My Pleasure and thanks for your super fast response :-)