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

add onClose prop for callback when the panel is closed #114

Closed DaniAkash closed 4 years ago

DaniAkash commented 5 years ago

Will add an onClose prop which will be called every time the panel is closed.

octopitus commented 5 years ago

The word close may not the right term if the draggableRange has bottom value higher 0. close is when something is going to be dismissed or gone (E.g Close modal, close drawer, close database connection...).

If you want is to be notified when the panel reaches the bottom, you can use onMomentumDragEnd or InteractionManager:

_handleOnMomentumEnd(value) {
  // Compare the value with the bottom of draggableRange
  if (value === 0) {

  }
}

// This method is called when you click a button to hide the panel
_hidePanel() {
  this._panel.hide()

  InteractionManager.runAfterInteractions(() => {
    // ...long-running synchronous task...
  });
}

<Panel
  ref={c => this._panel = c}
  onMomentumDragEnd={this._handleOnMomentumDragEnd}
/>
DaniAkash commented 5 years ago

Still i'd like to have a single handler to handle this. Will onHide be the right term?

octopitus commented 5 years ago

How about onBottomReached?

DaniAkash commented 5 years ago

Sure it will work. I'll update my PR

rgoldiez commented 5 years ago

Sure it will work. I'll update my PR

Any plans to update this PR?

daviswhitehead commented 5 years ago

Any chance we can get this PR merged? I'd love to use the onClose functionality!

jaredegan commented 4 years ago

This PR seems like exactly what I need, but I see two issues with it:

DaniAkash commented 4 years ago

@jaredegan i'll update the PR. Its been a long time

jaredegan commented 4 years ago

Thanks, Dani! I know how these things go, hopefully we can get it merged in.

DaniAkash commented 4 years ago

@jaredegan I have updated the PR

octopitus commented 4 years ago

Published in v2.4.0

jaredegan commented 4 years ago

Excellent! 🤘

jaredegan commented 4 years ago

@octopitus looks like 2.4.0 was not successfully published: https://www.npmjs.com/package/rn-sliding-up-panel

octopitus commented 4 years ago

@jaredegan Opps I published using wrong registry config 🤦‍♂

// Edit: Updated.