Merge branch 'feature/animation' into 'master'
Feature/animation See merge request !42
This commit is contained in:
@@ -152,13 +152,13 @@ - (void)stopAnimation {
|
||||
[self.headerNode callJSResponse:@"stopAnimation", nil];
|
||||
}
|
||||
|
||||
- (void)setProgressRotation:(CGFloat)rotation {
|
||||
[self.headerNode callJSResponse:@"setProgressRotation", @(rotation), nil];
|
||||
- (void)setPullingDistance:(CGFloat)distance {
|
||||
[self.headerNode callJSResponse:@"setPullingDistance", @(distance), nil];
|
||||
}
|
||||
|
||||
- (void)setRefreshing:(NSNumber *)refreshable withPromise:(DoricPromise *)promise {
|
||||
self.view.refreshing = [refreshable boolValue];
|
||||
[promise resolve:nil];
|
||||
[promise resolve:nil];
|
||||
}
|
||||
|
||||
- (void)setRefreshable:(NSNumber *)refreshing withPromise:(DoricPromise *)promise {
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
/*
|
||||
* Copyright [2019] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//
|
||||
// Created by pengfei.zhou on 2019/11/26.
|
||||
//
|
||||
@@ -24,7 +9,7 @@
|
||||
|
||||
- (void)stopAnimation;
|
||||
|
||||
- (void)setProgressRotation:(CGFloat)rotation;
|
||||
- (void)setPullingDistance:(CGFloat)rotation;
|
||||
@end
|
||||
|
||||
@interface DoricSwipeRefreshLayout : UIScrollView
|
||||
|
||||
@@ -68,7 +68,14 @@ - (BOOL)requestFromSubview:(UIView *)subview {
|
||||
return [super requestFromSubview:subview];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)layoutSelf:(CGSize)targetSize {
|
||||
if (self.contentOffset.y != 0) {
|
||||
return;
|
||||
}
|
||||
self.width = targetSize.width;
|
||||
self.height = targetSize.height;
|
||||
[self.headerView also:^(UIView *it) {
|
||||
@@ -109,7 +116,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
if (scrollView.contentOffset.y <= 0) {
|
||||
[self.swipePullingDelegate setProgressRotation:-scrollView.contentOffset.y / self.headerView.height * 2];
|
||||
[self.swipePullingDelegate setPullingDistance:-scrollView.contentOffset.y];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,31 +129,14 @@ - (void)setRefreshing:(BOOL)refreshing {
|
||||
return;
|
||||
}
|
||||
if (refreshing) {
|
||||
[self setContentOffset:CGPointMake(0, -self.headerView.height) animated:YES];
|
||||
self.scrollEnabled = NO;
|
||||
if (self.onRefreshBlock) {
|
||||
self.onRefreshBlock();
|
||||
}
|
||||
[UIView animateWithDuration:.3f
|
||||
animations:^{
|
||||
self.contentOffset = (CGPoint) {0, -self.headerView.height};
|
||||
self.contentInset = UIEdgeInsetsMake(self.headerView.height, 0, 0, 0);
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[self.swipePullingDelegate startAnimation];
|
||||
self.scrollEnabled = NO;
|
||||
}
|
||||
];
|
||||
} else {
|
||||
self.bounces = YES;
|
||||
[UIView animateWithDuration:.3f
|
||||
animations:^{
|
||||
self.contentOffset = (CGPoint) {0, 0};
|
||||
self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[self.swipePullingDelegate stopAnimation];
|
||||
self.scrollEnabled = YES;
|
||||
}
|
||||
];
|
||||
[self setContentOffset:(CGPoint) {0, 0} animated:YES];
|
||||
self.scrollEnabled = YES;
|
||||
}
|
||||
_refreshing = refreshing;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user