This repository was archived by the owner on Jun 3, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
ios/sdk/WeexSDK/Sources/Component Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 25
25
#import " WXComponent+Layout.h"
26
26
27
27
@interface WXRefreshComponent ()
28
+ {
29
+ NSTimeInterval _refreshStateTriggerTime;
30
+ }
28
31
29
32
@property (nonatomic ) BOOL displayState;
30
33
@property (nonatomic ) BOOL initFinished;
@@ -177,12 +180,23 @@ - (void)setDisplay
177
180
}
178
181
[_indicator start ];
179
182
[scrollerProtocol setContentOffset: offset animated: YES ];
183
+ _refreshStateTriggerTime = CFAbsoluteTimeGetCurrent ();
180
184
} else {
181
185
offset.y = 0 ;
182
186
[_indicator stop ];
183
- [UIView animateWithDuration: 0.25 animations: ^{
184
- [scrollerProtocol setContentOffset: offset];
185
- }];
187
+ if (CFAbsoluteTimeGetCurrent () - _refreshStateTriggerTime < 0.3 ) {
188
+ /* If javascript doesn't do any refreshing and only update 'display' attribute very quickly.
189
+ The previous '[scrollerProtocol setContentOffset:offset animated:YES];' is not finished,
190
+ we should also use '[scrollerProtocol setContentOffset:offset animated:YES]' to restore offset.
191
+ Or the scroller will not stop at 0.
192
+ */
193
+ [scrollerProtocol setContentOffset: offset animated: YES ];
194
+ }
195
+ else {
196
+ [UIView animateWithDuration: 0.25 animations: ^{
197
+ [scrollerProtocol setContentOffset: offset];
198
+ }];
199
+ }
186
200
}
187
201
188
202
/* If we are adding elements while refreshing, like this demo:http://dotwe.org/vue/f541ed72a121db8447a233b777003e8a
You can’t perform that action at this time.
0 commit comments