javascript - react native PanResponder to get current scrollView position -
i want current y-offset of scrollview using panresponder. did far, couldn't find way current y-offset
componentwillmount() { this._panresponder = panresponder.create({ onmoveshouldsetpanresponder: (evt, gesturestate) => true, onpanresponderrelease: (evt, gesturestate) => { console.log(this.scrollview) //this logs scrollview } }); } <scrollview ref={(view) => this._scrollview = view} {...this._panresponder.panhandlers}>
assuming touch release mean moment when 1 touch stops existing, can scrollview's ontouchend prop.
i using onscroll save offset somewhere , ontouchend offset.
<scrollview onscroll={(event) => { this.offsety = event.nativeevent.contentoffset.y; }} ontouchend={(event) => { console.log('offsety:', this.offsety); console.log('touch info:', event.nativeevent); }} > {content of scroll view} </scrollview>
if touch release meant there should 0 touches, can check event passed ontouchend.
Comments
Post a Comment