You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/04/01 09:00:18 UTC
[incubator-weex] branch master updated: [iOS] Ignore scroll action
if contentSize smaller than scroller frame.
This is an automated email from the ASF dual-hosted git repository.
moshen 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 ae3607d [iOS] Ignore scroll action if contentSize smaller than scroller frame.
new 58e96ee Merge pull request #2269 from sunshl/bugfix_scrollto
ae3607d is described below
commit ae3607db00e15e29e3539dd6899680156d78054d
Author: huanglei.hl <hu...@alibaba-inc.com>
AuthorDate: Mon Apr 1 16:55:00 2019 +0800
[iOS] Ignore scroll action if contentSize smaller than scroller frame.
* demo: http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
---
ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm | 7 +++++++
ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm | 9 +++++++++
2 files changed, 16 insertions(+)
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
index 6b99d5d..f01e81c 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
@@ -252,6 +252,13 @@
- (void)scrollToComponent:(WXComponent *)component withOffset:(CGFloat)offset animated:(BOOL)animated
{
+ UIScrollView *scrollView = (UIScrollView *)self.view;
+ // http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
+ // ignore scroll action if contentSize smaller than scroller frame
+ if (scrollView.contentSize.height < scrollView.frame.size.height) {
+ return;
+ }
+
CGPoint contentOffset = _tableView.contentOffset;
CGFloat contentOffsetY = 0;
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
index 98f061b..ba9b730 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
@@ -562,6 +562,15 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
- (void)scrollToComponent:(WXComponent *)component withOffset:(CGFloat)offset animated:(BOOL)animated
{
UIScrollView *scrollView = (UIScrollView *)self.view;
+ // http://dotwe.org/vue/aa1af34e5fc745c0f1520e346904682a
+ // ignore scroll action if contentSize smaller than scroller frame
+ if (_scrollDirection == WXScrollDirectionVertical && scrollView.contentSize.height < scrollView.frame.size.height) {
+ return;
+ }
+ if (_scrollDirection == WXScrollDirectionHorizontal && scrollView.contentSize.width < scrollView.frame.size.width) {
+ return;
+ }
+
CGPoint contentOffset = scrollView.contentOffset;
CGFloat scaleFactor = self.weexInstance.pixelScaleFactor;