You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2019/04/08 06:43:28 UTC
[incubator-weex] branch master updated: [iOS] Fix after very quick
refresh, scroller cannot stay at 0 point problem.
This is an automated email from the ASF dual-hosted git repository.
jianhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 5dbb79e [iOS] Fix after very quick refresh, scroller cannot stay at 0 point problem.
new 7ddd3a1 Merge pull request #2283 from wqyfavor/fix-refresh
5dbb79e is described below
commit 5dbb79e522d22c7d4d9465312b0adb0d01bd735a
Author: wqyfavor <qi...@taobao.com>
AuthorDate: Mon Apr 8 12:49:53 2019 +0800
[iOS] Fix after very quick refresh, scroller cannot stay at 0 point problem.
---
.../WeexSDK/Sources/Component/WXRefreshComponent.mm | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.mm
index 1bbe3cb..02d7f5c 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXRefreshComponent.mm
@@ -25,6 +25,9 @@
#import "WXComponent+Layout.h"
@interface WXRefreshComponent()
+{
+ NSTimeInterval _refreshStateTriggerTime;
+}
@property (nonatomic) BOOL displayState;
@property (nonatomic) BOOL initFinished;
@@ -177,12 +180,23 @@
}
[_indicator start];
[scrollerProtocol setContentOffset:offset animated:YES];
+ _refreshStateTriggerTime = CFAbsoluteTimeGetCurrent();
} else {
offset.y = 0;
[_indicator stop];
- [UIView animateWithDuration:0.25 animations:^{
- [scrollerProtocol setContentOffset:offset];
- }];
+ if (CFAbsoluteTimeGetCurrent() - _refreshStateTriggerTime < 0.3) {
+ /* If javascript doesn't do any refreshing and only update 'display' attribute very quickly.
+ The previous '[scrollerProtocol setContentOffset:offset animated:YES];' is not finished,
+ we should also use '[scrollerProtocol setContentOffset:offset animated:YES]' to restore offset.
+ Or the scroller will not stop at 0.
+ */
+ [scrollerProtocol setContentOffset:offset animated:YES];
+ }
+ else {
+ [UIView animateWithDuration:0.25 animations:^{
+ [scrollerProtocol setContentOffset:offset];
+ }];
+ }
}
/* If we are adding elements while refreshing, like this demo:http://dotwe.org/vue/f541ed72a121db8447a233b777003e8a