Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit ae3607d

Browse files
author
huanglei.hl
committed
[iOS] Ignore scroll action if contentSize smaller than scroller frame.
* demo: http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
1 parent 36dce32 commit ae3607d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm

+7
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ - (void)_handleFirstScreenTime
252252

253253
- (void)scrollToComponent:(WXComponent *)component withOffset:(CGFloat)offset animated:(BOOL)animated
254254
{
255+
UIScrollView *scrollView = (UIScrollView *)self.view;
256+
// http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
257+
// ignore scroll action if contentSize smaller than scroller frame
258+
if (scrollView.contentSize.height < scrollView.frame.size.height) {
259+
return;
260+
}
261+
255262
CGPoint contentOffset = _tableView.contentOffset;
256263
CGFloat contentOffsetY = 0;
257264

ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm

+9
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,15 @@ - (void)removeScrollToListener:(WXComponent *)target
562562
- (void)scrollToComponent:(WXComponent *)component withOffset:(CGFloat)offset animated:(BOOL)animated
563563
{
564564
UIScrollView *scrollView = (UIScrollView *)self.view;
565+
// http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
566+
// ignore scroll action if contentSize smaller than scroller frame
567+
if (_scrollDirection == WXScrollDirectionVertical && scrollView.contentSize.height < scrollView.frame.size.height) {
568+
return;
569+
}
570+
if (_scrollDirection == WXScrollDirectionHorizontal && scrollView.contentSize.width < scrollView.frame.size.width) {
571+
return;
572+
}
573+
565574

566575
CGPoint contentOffset = scrollView.contentOffset;
567576
CGFloat scaleFactor = self.weexInstance.pixelScaleFactor;

0 commit comments

Comments
 (0)