-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the axis-Y of the top #2
Comments
I wrote some code earlier to do this to figure out the bottom of a normal scroll view. var listViewScrollView = this.getScrollResponder();
this.refs.listview.requestAnimationFrame(() => {
listViewScrollView.refs.InnerScrollView.measure((x, y, width, height, offsetX, offsetY) => {
listViewScrollView.refs.ScrollView.measure((x_, y_, width_, height_, offsetX_, offsetY_) => {
//console.log("x=", x, "y=", y, "width=", width, "height=", height, "offsetX=", offsetX, "offsetY=", offsetY);
//console.log("x'=", x_, "y'=", y, "width'=", width_, "height'=", height_, "offsetX'=", offsetX_, "offsetY'=", offsetY_);
var scrollPadding = 3;
var scrollTo = height - height_ + y + scrollPadding;
// marginTop needs to be included
// offsetY needs to to be included, offsetY_ seems to always match it
// bigger offsetY means scrolled up; smaller offsetY means scrolled down
// when offsetY == InnerScrollView.height
// offsetY + InnerScrollView.height = ScrollView.height
// offsetY marginTop y_ y/height scrollTo marginTop - offsetY
// 0 131 0 533 405 131 - 0 = 131
// -122 -253 -253 533 405 -253 - (-122) = -131
//
var currentScrollTo = y - offsetY + offsetY_ + scrollPadding;
var delta = Math.abs(scrollTo - currentScrollTo);
var threshold = 45;
//console.log("scrollingTo:", scrollTo);
var doScroll;
if (opts.maybe) {
if (delta < threshold) {
doScroll = true;
} else {
doScroll = false;
}
} else {
doScroll = true;
}
//Ion.console.log("offsetY=", offsetY, "offsetY_=", offsetY_, "InnerScrollView.height=", height, "ScrollView.height=", height_, "y=", y, "y_=", y_, "doScroll=", doScroll, "scrollTo=", scrollTo, "marginTop=", this.props._conversationMarginTop, "inputHeight=", inputDimensions.height, "currentScrollTo=", currentScrollTo, "threshold=", threshold, "delta=", delta, "(y - height)=", (y - height));
//doScroll = false;
if (doScroll) {
if (opts.withoutAnimation) {
listViewScrollView.scrollWithoutAnimationTo(scrollTo);
} else {
listViewScrollView.scrollTo(scrollTo);
}
} else {
Ion.console.log("Not scrolling because too far apart and maybe");
}
//Ion.console.log("old _innerScrollViewOffsetY=", this._innerScrollViewOffsetY, "new _innerScrollViewOffsetY=", offsetY, "old _scrollViewOffsetY", this._scrollViewOffsetY, "new _scrollViewOffsetY=", offsetY_);
this._innerScrollViewOffsetY = offsetY;
this._scrollViewOffsetY = offsetY_;
if (callback) {
callback(scrollTo);
}
});
});
}); |
@ccheever how can I access the |
@lazywei Just something I wrote: getScrollResponder: function () {
return this.refs.listview.getScrollResponder();
}, |
@lazywei Did you solve it? <InvertibleScrollView
ref='messages'
inverted
automaticallyAdjustContentInsets={false}
contentInset={{bottom: 64}}
onScroll={this.handleScroll}
scrollEventThrottle={200}
>
{reloading}
{content}
{nextLoading}
</InvertibleScrollView> And I want to get scroll responser by: |
Actually I got the same error too.... -- Chih-Wei On Tue, Apr 28, 2015 at 6:02 PM, Michal Raška [email protected]
|
@lazywei @michalraska |
|
Hi,
When scrolling, I'd like to check if we are at the top-most because I'd like to load more messages when scroll to top-most. In original scroll view, I can check if the
to see if the
y
is less then 0. However, in inverted scroll view, the y is increasing when scrolling up. In such case, how can I tell if I've already scrolled to the top-most?Thanks.
The text was updated successfully, but these errors were encountered: