Comments (18)
你在什么时候调用endLoading,什么时候就开始回弹。自己掌握时间
from react-native-spring-scrollview.
你在什么时候调用endLoading,什么时候就开始回弹。自己掌握时间
onRefresh={this._onRefresh}
_onRefresh = () => {
setTimeout(() => {
// this.setState({
// })
this._scrollView.endRefresh();
}, 2000);
};
endLoading ?
from react-native-spring-scrollview.
你在什么时候调用endLoading,什么时候就开始回弹。自己掌握时间
`_onRefresh = () => {
setTimeout(() => {
// this.setState({
// })
this._scrollView.endRefresh();
},5000);
};
_onLoading = () => {
setTimeout(() => {
this._scrollView.endLoading()
}, 2000);
}`
是这样?,我还是不会
from react-native-spring-scrollview.
你在什么时候调用endLoading,什么时候就开始回弹。自己掌握时间
老大,我说的是下拉刷新,refreshHeader是我自定义的
from react-native-spring-scrollview.
是一样的,你调用endRefresh函数就开始回弹,这个你自己控制啊。
from react-native-spring-scrollview.
是一样的,你调用endRefresh函数就开始回弹,这个你自己控制啊。
我的意思是最后一个状态显示的文字 结束刷新一出来就立马回弹了,都没来得及看,这能控制,最后一个状态文字 结束刷新停留个2秒后,然后再回弹?
from react-native-spring-scrollview.
是一样的,你调用endRefresh函数就开始回弹,这个你自己控制啊。
onRefresh={()=>{
setTimeout(()=>{
this._scrollView.endRefresh();
},2000);
}}
我这样写,最后一个状态文字刷新完成一出现立马回弹了,如果字数多点,就看不出写的什么
from react-native-spring-scrollview.
我想了一天了,确实实现不了我的需求
from react-native-spring-scrollview.
onRefresh={()=>{
setTimeout(()=>{
this._scrollView.endLoading(); // endLoading不会结束refreshing状态,无效
// this._scrollView.endRefresh(); //此处调用立马变成rebound状态同时回弹,不能控制停留
},1000);
}}
refreshHeader={SimpleRefreshHeader}
from react-native-spring-scrollview.
我的需求就是 使用demo里的NormalHeader,怎么做到最后一个状态Refresh completed文字能停留2秒
from react-native-spring-scrollview.
没有提供这种功能定制化,你要实现可以fork去自己改:
iOS: STSpringScrollView.m
- (void)endRefresh {
if ([self hitRefreshStatus:@[@"refreshing"]]) {
self.refreshStatus = @"rebound";
[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0) animated:YES];
}
}
- (void)endLoading {
if ([self hitLoadingStatus:@[@"loading"]]) {
self.loadingStatus = @"rebound";
[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height-self.bounds.size.height) animated:YES];
}
}
安卓:SpringScrollView.java
public void endRefresh() {
if (!refreshStatus.equals("refreshing")) return;
refreshStatus = "rebound";
if (verticalAnimation != null) verticalAnimation.cancel();
contentInsets.top = 0;
verticalAnimation = new DecelerateAnimation(contentOffset.y, 0, 500) {
@Override
protected void onUpdate(float value) {
setContentOffset(contentOffset.x, value);
}
};
verticalAnimation.start();
}
public void endLoading() {
if (!loadingStatus.equals("loading")) return;
loadingStatus = "rebound";
if (verticalAnimation != null) verticalAnimation.cancel();
contentInsets.bottom = 0;
verticalAnimation = new DecelerateAnimation(contentOffset.y, contentSize.height - size.height, 500) {
@Override
protected void onUpdate(float value) {
setContentOffset(contentOffset.x, value);
}
};
verticalAnimation.start();
}
要先发送状态改变事件,定时2秒后再调用对应的动画回弹:
安卓发送事件是:sendOnScrollEvent
iOS是
- (void)sendScrollEventWithName:(NSString *)eventName
scrollView:(UIScrollView *)scrollView
userData:(NSDictionary *)userData{
NSMutableDictionary *data = [NSMutableDictionary dictionaryWithDictionary:userData];
[data setObject:self.refreshStatus forKey:@"refreshStatus"];
[data setObject:self.loadingStatus forKey:@"loadingStatus"];
[super sendScrollEventWithName:eventName scrollView:scrollView userData:data];
}
from react-native-spring-scrollview.
还有要注意的是,发送事件在某些特定情况下收不到。这个是RN一直以来的bug,很多做自定义下拉刷新的人都遇到过。我采取的策略是在滑动的时候一直把当前状态往js发,丢失一两次事件无所谓。反正滑动会发很多事件。
from react-native-spring-scrollview.
还有要注意的是,发送事件在某些特定情况下收不到。这个是RN一直以来的bug,很多做自定义下拉刷新的人都遇到过。我采取的策略是在滑动的时候一直把当前状态往js发,丢失一两次事件无所谓。反正滑动会发很多事件。
暂时没有原生能力修改,,,挺遗憾了
from react-native-spring-scrollview.
其实你也不用这样修改代码,一些折中的方法也是可行的。你要是能够在刷新完成以后给你的自定义SimpleRefreshHeader
发送消息,让你的SimpleRefreshHeader
显示成“刷新完成”的状态,然后在两秒后再调用endRefresh也是可行的。
from react-native-spring-scrollview.
其实你也不用这样修改代码,一些折中的方法也是可行的。你要是能够在刷新完成以后给你的自定义
SimpleRefreshHeader
发送消息,让你的SimpleRefreshHeader
显示成“刷新完成”的状态,然后在两秒后再调用endRefresh也是可行的。
我试试,听着好像行
from react-native-spring-scrollview.
其实你也不用这样修改代码,一些折中的方法也是可行的。你要是能够在刷新完成以后给你的自定义
SimpleRefreshHeader
发送消息,让你的SimpleRefreshHeader
显示成“刷新完成”的状态,然后在两秒后再调用endRefresh也是可行的。
好像不对,我下拉松手后一直是refreshing 状态,我没办法刷新完成以后给我的自定义SimpleRefreshHeader 发送消息,这一部我只能发endRefrsh,但是我一写endRefresh就立马结束。
因为这个状态refreshing - rebound ,中间没有什么可以控制了,只能endRefresh来控制
from react-native-spring-scrollview.
可以考虑发送全局消息,这是折中办法。这样不用修改源码,不然的话需要需改
SpringScrollView.js:
_renderRefreshHeader() {
const { onRefresh, refreshHeader: Refresh } = this.props;
const measured = this._height !== undefined && this._contentHeight !== undefined;
if (!measured) return null;
return (
onRefresh && (
<Animated.View style={this._getRefreshHeaderStyle()}>
<Refresh
ref={ref => (this._refreshHeader = ref)}
offset={this._offsetY}
maxHeight={Refresh.height}
/>
</Animated.View>
)
);
}
或者加一个方法调用this._refreshHeader.onMessage ,方法很多。
from react-native-spring-scrollview.
可以考虑发送全局消息,这是折中办法。这样不用修改源码,不然的话需要需改
SpringScrollView.js:_renderRefreshHeader() { const { onRefresh, refreshHeader: Refresh } = this.props; const measured = this._height !== undefined && this._contentHeight !== undefined; if (!measured) return null; return ( onRefresh && ( <Animated.View style={this._getRefreshHeaderStyle()}> <Refresh ref={ref => (this._refreshHeader = ref)} offset={this._offsetY} maxHeight={Refresh.height} /> </Animated.View> ) ); }
或者加一个方法调用this._refreshHeader.onMessage ,方法很多。
我这样已经实现了我要的效果了,就是不知道有没有其他性能什么的问题
from react-native-spring-scrollview.
Related Issues (20)
- Error to install dependency on RN 0.71.1 HOT 1
- 0.72版本install不了啊。希望保持更新啊
- DEAD LIB
- V3.0.2 还是没有修复 滑动误触点击事件 HOT 7
- 列表内item点击失效 HOT 7
- 安卓下嵌套ScrollView,scrollview内容不滚动,ios可以 HOT 4
- 无障碍读屏不能滑动的问题 HOT 2
- react-native-spring-scrollview 内嵌 SectionList
- TS+RN 项目里报错 HOT 1
- v4.0 报错 HOT 2
- v4.0分支里面,不需要原生了吗?
- Is the npm package not being maintained?
- v4.0分支出现错误 Cannot read property 'contentOffset' of undefined HOT 4
- 瀑布流中怎么设置左右的宽度 HOT 1
- "若手指在滑动过程中始终不离开屏幕会造成列表中元素无法点击"的解决方案 HOT 1
- Unexpected token, expected "," (2:8) HOT 5
- Error: "Expected a type"
- Item 曝光
- 瀑布流card 高度不确定
- Error with RN Version 0.69.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-spring-scrollview.