You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/08/09 06:50:23 UTC

[1/6] incubator-weex git commit: +[ios] recyclerComponent add drag method

Repository: incubator-weex
Updated Branches:
  refs/heads/0.16-dev 1ebd484ed -> ca211a54d


+[ios] recyclerComponent add drag method


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ddc99ccf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ddc99ccf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ddc99ccf

Branch: refs/heads/0.16-dev
Commit: ddc99ccf14a388368bb1cff5bd84e4561a1d345e
Parents: 58aaee6
Author: ximu <xi...@alibaba-inc.com>
Authored: Wed Jul 26 14:51:06 2017 +0800
Committer: ximu <xi...@alibaba-inc.com>
Committed: Wed Jul 26 14:51:06 2017 +0800

----------------------------------------------------------------------
 .../Component/Recycler/WXRecyclerComponent.m    | 222 ++++++++++++++++++-
 1 file changed, 217 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ddc99ccf/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
index c954e9f..523bd83 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
@@ -31,6 +31,7 @@
 #import "WXUtility.h"
 #import "WXMonitor.h"
 #import "NSObject+WXSwizzle.h"
+#import "WXComponent+Events.h"
 
 static NSString * const kCollectionCellReuseIdentifier = @"WXRecyclerCell";
 static NSString * const kCollectionHeaderReuseIdentifier = @"WXRecyclerHeader";
@@ -42,6 +43,12 @@ typedef enum : NSUInteger {
     WXRecyclerLayoutTypeGrid,
 } WXRecyclerLayoutType;
 
+typedef enum : NSUInteger {
+    WXRecyclerDragTriggerNormal,
+    WXRecyclerDragTriggerPan
+} WXRecyclerDragTriggerType;
+
+
 @interface WXCollectionView : UICollectionView
 
 @end
@@ -75,7 +82,7 @@ typedef enum : NSUInteger {
 - (void)prepareForReuse
 {
     [super prepareForReuse];
-
+    
     WXCellComponent *cellComponent = (WXCellComponent *)self.wx_component;
     if (cellComponent.isRecycle && [cellComponent isViewLoaded] && [self.contentView.subviews containsObject:cellComponent.view]) {
         [cellComponent _unloadViewWithReusing:YES];
@@ -89,6 +96,15 @@ typedef enum : NSUInteger {
 @property (nonatomic, strong, readonly) WXRecyclerDataController *dataController;
 @property (nonatomic, strong, readonly) WXRecyclerUpdateController *updateController;
 @property (nonatomic, weak, readonly) UICollectionView *collectionView;
+@property (nonatomic, strong) UILongPressGestureRecognizer *currentLongPress;
+@property (nonatomic, strong) NSIndexPath  *startIndexPath;
+@property (nonatomic, strong) NSIndexPath  *dragingIndexPath;
+@property (nonatomic, strong) NSIndexPath  *targetIndexPath;
+@property (nonatomic, strong) NSMutableArray *excludedAry;
+@property (nonatomic, strong) UICollectionViewCell *dragingCell;
+@property (nonatomic, assign) BOOL isDragable;
+@property (nonatomic, assign) BOOL isDragAnchor;
+@property (nonatomic, assign) WXRecyclerDragTriggerType dragTriggerType;
 
 @end
 
@@ -106,6 +122,15 @@ typedef enum : NSUInteger {
     if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) {
         [self _fillPadding];
         
+        if ([attributes[@"draggable"] boolValue]) {
+            if([attributes[@"dragTriggerType"]  isEqual: @"pan"]){
+                _dragTriggerType = WXRecyclerDragTriggerPan;
+            }
+            _isDragable = YES;
+        }else{
+            _isDragable = NO;
+        }
+        
         if ([type isEqualToString:@"waterfall"] || (attributes[@"layout"] && [attributes[@"layout"] isEqualToString:@"multi-column"])) {
             // TODO: abstraction
             _layoutType = WXRecyclerLayoutTypeMultiColumn;
@@ -115,7 +140,7 @@ typedef enum : NSUInteger {
             layout.columnWidth = [WXConvert WXLength:attributes[@"columnWidth"] isFloat:YES scaleFactor:scaleFactor] ? : [WXLength lengthWithFloat:0.0 type:WXLengthTypeAuto];
             layout.columnCount = [WXConvert WXLength:attributes[@"columnCount"] isFloat:NO scaleFactor:1.0] ? : [WXLength lengthWithInt:1 type:WXLengthTypeFixed];
             layout.columnGap = [self _floatValueForColumnGap:([WXConvert WXLength:attributes[@"columnGap"] isFloat:YES scaleFactor:scaleFactor] ? : [WXLength lengthWithFloat:0.0 type:WXLengthTypeNormal])];
-
+            
             layout.delegate = self;
         } else {
             _collectionViewlayout = [UICollectionViewLayout new];
@@ -156,6 +181,21 @@ typedef enum : NSUInteger {
     [_collectionView registerClass:[WXCollectionViewCell class] forCellWithReuseIdentifier:kCollectionCellReuseIdentifier];
     [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:kCollectionSupplementaryViewKindHeader withReuseIdentifier:kCollectionHeaderReuseIdentifier];
     
+    _isDragAnchor = NO;
+    
+    _excludedAry = [[NSMutableArray alloc] init];
+    [_collectionView registerClass:[WXCollectionViewCell class] forCellWithReuseIdentifier:kCollectionCellReuseIdentifier];
+    [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:kCollectionSupplementaryViewKindHeader withReuseIdentifier:kCollectionHeaderReuseIdentifier];
+    
+    _currentLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+    _currentLongPress.minimumPressDuration = 0.3f;
+    [_collectionView addGestureRecognizer:_currentLongPress];
+    
+    _dragingCell = [[WXCollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100/2.0f)];
+    _dragingCell.hidden = true;
+    [_collectionView addSubview:_dragingCell];
+    
+    
     [self performUpdatesWithCompletion:^(BOOL finished) {
         
     }];
@@ -177,6 +217,16 @@ typedef enum : NSUInteger {
         CGFloat scaleFactor = self.weexInstance.pixelScaleFactor;
         WXMultiColumnLayout *layout = (WXMultiColumnLayout *)_collectionViewlayout;
         BOOL needUpdateLayout = NO;
+        
+        if ([attributes[@"draggable"] boolValue]) {
+            if([attributes[@"dragTriggerType"]  isEqual: @"pan"]){
+                _dragTriggerType = WXRecyclerDragTriggerPan;
+            }
+            _isDragable = YES;
+        }else{
+            _isDragable = NO;
+        }
+        
         if (attributes[@"columnWidth"]) {
             layout.columnWidth = [WXConvert WXLength:attributes[@"columnWidth"] isFloat:YES scaleFactor:scaleFactor];
             needUpdateLayout = YES;
@@ -261,7 +311,7 @@ typedef enum : NSUInteger {
     }
     
     [_collectionView setContentOffset:contentOffset animated:animated];
-
+    
 }
 
 - (void)performUpdatesWithCompletion:(void (^)(BOOL finished))completion
@@ -297,7 +347,7 @@ typedef enum : NSUInteger {
     
     WXPerformBlockOnMainThread(^{
         [self performUpdatesWithCompletion:^(BOOL finished) {
-    
+            
         }];
     });
 }
@@ -353,6 +403,8 @@ typedef enum : NSUInteger {
     
     cellView.wx_component = contentView.wx_component;
     
+    [self goThroughAnchor:cellView.wx_component indexPath:indexPath];
+    
     if (contentView.superview == cellView.contentView) {
         return cellView;
     }
@@ -377,7 +429,7 @@ typedef enum : NSUInteger {
             for (UIView *view in reusableView.subviews) {
                 [view removeFromSuperview];
             }
-
+            
             [reusableView addSubview:contentView];
         }
     }
@@ -655,6 +707,166 @@ typedef enum : NSUInteger {
     });
 }
 
+#pragma mark - dragMethod
+- (void)longPressMethod:(UILongPressGestureRecognizer*)gesture
+{
+    if (_isDragable) {
+        switch (gesture.state) {
+            case UIGestureRecognizerStateBegan:
+                [self dragBegin:gesture];
+                break;
+            case UIGestureRecognizerStateChanged:
+                [self dragChanged:gesture];
+                break;
+            case UIGestureRecognizerStateEnded:
+                [self dragEnd:gesture];
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+- (void)dragBegin:(UILongPressGestureRecognizer *)gesture{
+    
+    CGPoint point = [gesture locationInView:_collectionView];
+    
+    _startIndexPath = [self getDragingIndexPathWithPoint:point];
+    if (!_startIndexPath) {
+        return;
+    }
+    
+    [self fireEvent:@"dragstart" params:@{@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
+    
+    _dragingIndexPath = [self getDragingIndexPathWithPoint:point];
+    if (!_dragingIndexPath) {
+        return;
+    }
+    
+    [_collectionView bringSubviewToFront:_dragingCell];
+    _dragingCell.frame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
+    _dragingCell.hidden = false;
+    [UIView animateWithDuration:0.3 animations:^{
+        [_dragingCell setTransform:CGAffineTransformMakeScale(1.2, 1.2)];
+    }];
+}
+
+- (void)dragChanged:(UILongPressGestureRecognizer *)gesture{
+    
+    if (!_startIndexPath) {
+        return;
+    }
+    CGPoint point = [gesture locationInView:_collectionView];
+    _dragingCell.center = point;
+    _targetIndexPath = [self getTargetIndexPathWithPoint:point];
+    
+    if (_targetIndexPath && _dragingIndexPath && (_targetIndexPath.section == _startIndexPath.section)){
+        [_collectionView moveItemAtIndexPath:_dragingIndexPath toIndexPath:_targetIndexPath];
+        _dragingIndexPath = _targetIndexPath;
+    }
+}
+
+- (void)dragEnd:(UILongPressGestureRecognizer *)gesture{
+    
+    if (!_startIndexPath || !_dragingIndexPath) {
+        return;
+    }
+    
+    [self fireEvent:@"dragend" params:@{@"toIndex":[NSString stringWithFormat:@"%ld",(long)_dragingIndexPath.row],@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
+    
+    CGRect endFrame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
+    
+    __weak typeof(self) weakSelf = self;
+    [UIView animateWithDuration:0.3 animations:^{
+        [weakSelf.dragingCell setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
+        weakSelf.dragingCell.frame = endFrame;
+    } completion:^(BOOL finished) {
+        weakSelf.dragingCell.hidden = YES;
+        NSMutableArray *oldComponents = [[NSMutableArray alloc] initWithArray:weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents];
+        if(oldComponents.count > 1){
+            WXCellComponent *startComponent = weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents[weakSelf.startIndexPath.item];
+            [oldComponents removeObject:startComponent];
+            [oldComponents insertObject:startComponent atIndex:weakSelf.targetIndexPath.item];
+            weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents = oldComponents;
+        }
+    }];
+}
+
+- (NSIndexPath *)getDragingIndexPathWithPoint:(CGPoint)point{
+    NSIndexPath *dragingIndexPath = nil;
+    for (NSIndexPath *indexPath in [_collectionView indexPathsForVisibleItems]){
+        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame,point)) {
+            dragingIndexPath = indexPath;
+            break;
+        }
+    }
+    
+    BOOL isExcluded = NO;
+    if (dragingIndexPath) {
+        for (NSIndexPath *indexPath in _excludedAry) {
+            if (indexPath.row == dragingIndexPath.row) {
+                isExcluded = YES;
+            }
+        }
+    }
+    return isExcluded?nil:dragingIndexPath;
+}
+
+- (NSIndexPath *)getTargetIndexPathWithPoint:(CGPoint)point{
+    NSIndexPath *targetIndexPath = nil;
+    for (NSIndexPath *indexPath in _collectionView.indexPathsForVisibleItems) {
+        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame, point)) {
+            targetIndexPath = indexPath;
+        }
+    }
+    return targetIndexPath;
+}
+
+
+- (void)goThroughAnchor:(WXComponent *)wxComponent indexPath:(NSIndexPath *)indexPath{
+    if (wxComponent.attributes && [wxComponent.attributes[@"dragExcluded"] boolValue]){
+        [_excludedAry addObject:indexPath];
+        NSSet *set = [NSSet setWithArray:_excludedAry];
+        [_excludedAry removeAllObjects];
+        [_excludedAry addObjectsFromArray:[set allObjects]];
+    }
+    
+    //遍历获取锚点
+    NSMutableArray *subviewComponents = [[NSMutableArray alloc] init];
+    [subviewComponents addObjectsFromArray:wxComponent.subcomponents];
+    WXComponent *anchorComponent;
+    for (int i = 0 ; i < subviewComponents.count ; i++){
+        WXComponent *compoent = subviewComponents[i];
+        if (compoent.attributes[@"dragAnchor"]) {
+            anchorComponent = compoent;
+            _isDragAnchor = YES;
+            break;
+        }
+        
+        if (compoent.subcomponents && compoent.subcomponents.count && compoent.subcomponents.count > 0) {
+            [subviewComponents addObjectsFromArray:compoent.subcomponents];
+        }
+    }
+    
+    if (anchorComponent) {
+        //去除全局UILongPressGestureRecognizer手势
+        if (_currentLongPress) {
+            [self.collectionView removeGestureRecognizer:_currentLongPress];
+            _currentLongPress = nil;
+        }
+        
+        //添加锚点的手势
+        if (_dragTriggerType == WXRecyclerDragTriggerPan) {
+            UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+            [anchorComponent.view addGestureRecognizer:panGestureRecognizer];
+            
+        }else{
+            UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+            [anchorComponent.view addGestureRecognizer:longPressGestureRecognizer];
+        }
+    }
+}
+
 - (void)fixedFlickerSelector
 {
     // DO NOT delete this method.

[2/6] incubator-weex git commit: +[ios] add WXRecyclerDragController

Posted by cx...@apache.org.
+[ios] add WXRecyclerDragController


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/82416393
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/82416393
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/82416393

Branch: refs/heads/0.16-dev
Commit: 824163937ecf0b882345bb179ca731e06d7a0411
Parents: ddc99cc
Author: ximu <xi...@alibaba-inc.com>
Authored: Tue Aug 1 10:58:44 2017 +0800
Committer: ximu <xi...@alibaba-inc.com>
Committed: Tue Aug 1 10:58:44 2017 +0800

----------------------------------------------------------------------
 .../Recycler/WXRecyclerDragController.h         |  41 ++++
 .../Recycler/WXRecyclerDragController.m         | 200 +++++++++++++++++++
 2 files changed, 241 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/82416393/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
new file mode 100644
index 0000000..a5f70b7
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
@@ -0,0 +1,41 @@
+//
+//  WXRecyclerDragController.h
+//  Pods
+//
+//  Created by ximu on 2017/7/31.
+//
+//
+
+#import <Foundation/Foundation.h>
+#import "WXSectionDataController.h"
+#import "WXComponent.h"
+
+@class WXRecyclerDragController;
+
+typedef enum : NSUInteger {
+    WXRecyclerDragTriggerNormal,
+    WXRecyclerDragTriggerPan
+} WXRecyclerDragTriggerType;
+
+
+@protocol WXRecyclerDragControllerDelegate <NSObject>
+- (void)dragFireEvent:(NSString *)eventName params:(NSDictionary *)params;
+- (void)updateDataSource;
+
+@end
+
+@interface WXRecyclerDragController : NSObject
+@property (nonatomic,weak) id<WXRecyclerDragControllerDelegate> delegate;
+@property (nonatomic,weak) UICollectionView *collectionView;
+@property (nonatomic, strong) UILongPressGestureRecognizer *currentLongPress;
+@property (nonatomic, strong) NSIndexPath  *startIndexPath;
+@property (nonatomic, strong) NSIndexPath  *dragingIndexPath;
+@property (nonatomic, strong) NSIndexPath  *targetIndexPath;
+@property (nonatomic, strong) NSMutableArray *excludedAry;
+@property (nonatomic, strong) UICollectionViewCell *dragingCell;
+@property (nonatomic, assign) BOOL isDragable;
+@property (nonatomic, assign) BOOL isDragAnchor;
+@property (nonatomic, assign) WXRecyclerDragTriggerType dragTriggerType;
+
+- (void)goThroughAnchor:(WXComponent *)wxComponent indexPath:(NSIndexPath *)indexPath;
+@end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/82416393/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
new file mode 100644
index 0000000..b3939c0
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
@@ -0,0 +1,200 @@
+//
+//  WXRecyclerDragController.m
+//  Pods
+//
+//  Created by ximu on 2017/7/31.
+//
+//
+
+#import "WXRecyclerDragController.h"
+
+
+@implementation WXRecyclerDragController
+
+- (instancetype)init{
+    self = [super init];
+    if (self) {
+        _excludedAry = [[NSMutableArray alloc] init];
+        _isDragAnchor = NO;
+
+    }
+    return self;
+}
+
+- (void)setCollectionView:(UICollectionView *)collectionView{
+    _collectionView = collectionView;
+    _currentLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+    _currentLongPress.minimumPressDuration = 0.3f;
+    [_collectionView addGestureRecognizer:_currentLongPress];
+}
+
+- (void)setDragingCell:(UICollectionViewCell *)dragingCell{
+    _dragingCell = dragingCell;
+    _dragingCell.hidden = true;
+    [_collectionView addSubview:_dragingCell];
+}
+
+
+- (void)goThroughAnchor:(WXComponent *)wxComponent indexPath:(NSIndexPath *)indexPath{
+    if (wxComponent.attributes && [wxComponent.attributes[@"dragExcluded"] boolValue]){
+        [_excludedAry addObject:indexPath];
+        NSSet *set = [NSSet setWithArray:_excludedAry];
+        [_excludedAry removeAllObjects];
+        [_excludedAry addObjectsFromArray:[set allObjects]];
+    }
+    
+    //遍历获取锚点
+    NSMutableArray *subviewComponents = [[NSMutableArray alloc] init];
+    [subviewComponents addObjectsFromArray:wxComponent.subcomponents];
+    WXComponent *anchorComponent;
+    for (int i = 0 ; i < subviewComponents.count ; i++){
+        WXComponent *compoent = subviewComponents[i];
+        if (compoent.attributes[@"dragAnchor"]) {
+            anchorComponent = compoent;
+            _isDragAnchor = YES;
+            break;
+        }
+        
+        if (compoent.subcomponents && compoent.subcomponents.count && compoent.subcomponents.count > 0) {
+            [subviewComponents addObjectsFromArray:compoent.subcomponents];
+        }
+    }
+    
+    if (anchorComponent) {
+        //去除全局UILongPressGestureRecognizer手势
+        if (_currentLongPress) {
+            [self.collectionView removeGestureRecognizer:_currentLongPress];
+            _currentLongPress = nil;
+        }
+        
+        //添加锚点的手势
+        if (_dragTriggerType == WXRecyclerDragTriggerPan) {
+            UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+            [anchorComponent.view addGestureRecognizer:panGestureRecognizer];
+            
+        }else{
+            UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
+            [anchorComponent.view addGestureRecognizer:longPressGestureRecognizer];
+        }
+    }
+}
+
+#pragma mark - dragMethod
+- (void)longPressMethod:(UILongPressGestureRecognizer*)gesture
+{
+    if (_isDragable) {
+        switch (gesture.state) {
+            case UIGestureRecognizerStateBegan:
+                [self dragBegin:gesture];
+                break;
+            case UIGestureRecognizerStateChanged:
+                [self dragChanged:gesture];
+                break;
+            case UIGestureRecognizerStateEnded:
+                [self dragEnd:gesture];
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+- (void)dragBegin:(UILongPressGestureRecognizer *)gesture{
+    
+    CGPoint point = [gesture locationInView:_collectionView];
+    
+    _startIndexPath = [self getDragingIndexPathWithPoint:point];
+    if (!_startIndexPath) {
+        return;
+    }
+    
+    if ([self.delegate respondsToSelector:@selector(fireEvent:params:)]) {
+        [self.delegate dragFireEvent:@"dragstart" params:@{@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
+    }
+    
+    _dragingIndexPath = [self getDragingIndexPathWithPoint:point];
+    if (!_dragingIndexPath) {
+        return;
+    }
+    
+    [_collectionView bringSubviewToFront:_dragingCell];
+    _dragingCell.frame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
+    _dragingCell.hidden = false;
+    [UIView animateWithDuration:0.3 animations:^{
+        [_dragingCell setTransform:CGAffineTransformMakeScale(1.2, 1.2)];
+    }];
+}
+
+- (void)dragChanged:(UILongPressGestureRecognizer *)gesture{
+    
+    if (!_startIndexPath) {
+        return;
+    }
+    CGPoint point = [gesture locationInView:_collectionView];
+    _dragingCell.center = point;
+    _targetIndexPath = [self getTargetIndexPathWithPoint:point];
+    
+    if (_targetIndexPath && _dragingIndexPath && (_targetIndexPath.section == _startIndexPath.section)){
+        [_collectionView moveItemAtIndexPath:_dragingIndexPath toIndexPath:_targetIndexPath];
+        _dragingIndexPath = _targetIndexPath;
+    }
+}
+
+- (void)dragEnd:(UILongPressGestureRecognizer *)gesture{
+    
+    if (!_startIndexPath || !_dragingIndexPath) {
+        return;
+    }
+    if ([self.delegate respondsToSelector:@selector(fireEvent:params:)]) {
+        [self.delegate dragFireEvent:@"dragend" params:@{@"toIndex":[NSString stringWithFormat:@"%ld",(long)_dragingIndexPath.row],@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
+    }
+    
+    CGRect endFrame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
+    
+    __weak typeof(self) weakSelf = self;
+    [UIView animateWithDuration:0.3 animations:^{
+        [weakSelf.dragingCell setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
+        weakSelf.dragingCell.frame = endFrame;
+    } completion:^(BOOL finished) {
+        weakSelf.dragingCell.hidden = YES;
+        if ([weakSelf.delegate respondsToSelector:@selector(updateDataSource)]) {
+            [weakSelf.delegate updateDataSource];
+        }
+        
+    }];
+}
+
+- (NSIndexPath *)getDragingIndexPathWithPoint:(CGPoint)point{
+    NSIndexPath *dragingIndexPath = nil;
+    for (NSIndexPath *indexPath in [_collectionView indexPathsForVisibleItems]){
+        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame,point)) {
+            dragingIndexPath = indexPath;
+            break;
+        }
+    }
+    
+    BOOL isExcluded = NO;
+    if (dragingIndexPath) {
+        for (NSIndexPath *indexPath in _excludedAry) {
+            if (indexPath.row == dragingIndexPath.row) {
+                isExcluded = YES;
+            }
+        }
+    }
+    return isExcluded?nil:dragingIndexPath;
+}
+
+- (NSIndexPath *)getTargetIndexPathWithPoint:(CGPoint)point{
+    NSIndexPath *targetIndexPath = nil;
+    for (NSIndexPath *indexPath in _collectionView.indexPathsForVisibleItems) {
+        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame, point)) {
+            targetIndexPath = indexPath;
+        }
+    }
+    return targetIndexPath;
+}
+
+- (void)dealloc{
+    
+}
+@end

[5/6] incubator-weex git commit: * [ios]WXRecylerDragController remove Notes

Posted by cx...@apache.org.
* [ios]WXRecylerDragController remove Notes


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/c1519868
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/c1519868
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/c1519868

Branch: refs/heads/0.16-dev
Commit: c151986854454e3b48aa599e9df0d7bf500b61f8
Parents: c6e1dbe
Author: ximu <xi...@alibaba-inc.com>
Authored: Wed Aug 2 10:46:08 2017 +0800
Committer: ximu <xi...@alibaba-inc.com>
Committed: Wed Aug 2 10:46:08 2017 +0800

----------------------------------------------------------------------
 .../Recycler/WXRecyclerDragController.h         | 25 ++++++++++++-----
 .../Recycler/WXRecyclerDragController.m         | 28 +++++++++++++-------
 2 files changed, 36 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1519868/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
index a5f70b7..d561de9 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.h
@@ -1,10 +1,21 @@
-//
-//  WXRecyclerDragController.h
-//  Pods
-//
-//  Created by ximu on 2017/7/31.
-//
-//
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
 
 #import <Foundation/Foundation.h>
 #import "WXSectionDataController.h"

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c1519868/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
index b3939c0..5538cf9 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDragController.m
@@ -1,10 +1,21 @@
-//
-//  WXRecyclerDragController.m
-//  Pods
-//
-//  Created by ximu on 2017/7/31.
-//
-//
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
 
 #import "WXRecyclerDragController.h"
 
@@ -43,7 +54,6 @@
         [_excludedAry addObjectsFromArray:[set allObjects]];
     }
     
-    //遍历获取锚点
     NSMutableArray *subviewComponents = [[NSMutableArray alloc] init];
     [subviewComponents addObjectsFromArray:wxComponent.subcomponents];
     WXComponent *anchorComponent;
@@ -61,13 +71,11 @@
     }
     
     if (anchorComponent) {
-        //去除全局UILongPressGestureRecognizer手势
         if (_currentLongPress) {
             [self.collectionView removeGestureRecognizer:_currentLongPress];
             _currentLongPress = nil;
         }
         
-        //添加锚点的手势
         if (_dragTriggerType == WXRecyclerDragTriggerPan) {
             UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
             [anchorComponent.view addGestureRecognizer:panGestureRecognizer];

[6/6] incubator-weex git commit: Merge branch 'dev_recycle_drag' of https://github.com/lcgithub/incubator-weex into 0.16-dev

Posted by cx...@apache.org.
Merge branch 'dev_recycle_drag' of https://github.com/lcgithub/incubator-weex into 0.16-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ca211a54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ca211a54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ca211a54

Branch: refs/heads/0.16-dev
Commit: ca211a54dfa30155b473b5f513be0dbb1fd70817
Parents: 1ebd484 c151986
Author: cxfeng <cx...@apache.org>
Authored: Wed Aug 9 14:50:11 2017 +0800
Committer: cxfeng <cx...@apache.org>
Committed: Wed Aug 9 14:50:11 2017 +0800

----------------------------------------------------------------------
 .../Component/Recycler/WXRecyclerComponent.m    |  58 +++++-
 .../Recycler/WXRecyclerDragController.h         |  52 +++++
 .../Recycler/WXRecyclerDragController.m         | 208 +++++++++++++++++++
 3 files changed, 312 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


[4/6] incubator-weex git commit: -[ios] remove drag methods from WXRecyclerComponent

Posted by cx...@apache.org.
-[ios] remove drag methods from WXRecyclerComponent


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/c6e1dbe2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/c6e1dbe2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/c6e1dbe2

Branch: refs/heads/0.16-dev
Commit: c6e1dbe260c63ea34a02d31fd6c104099018c9c4
Parents: 62c1270
Author: ximu <xi...@alibaba-inc.com>
Authored: Tue Aug 1 11:06:41 2017 +0800
Committer: ximu <xi...@alibaba-inc.com>
Committed: Tue Aug 1 11:06:41 2017 +0800

----------------------------------------------------------------------
 .../Component/Recycler/WXRecyclerComponent.m    | 226 +++----------------
 1 file changed, 30 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c6e1dbe2/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
index 523bd83..1164472 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.m
@@ -32,6 +32,7 @@
 #import "WXMonitor.h"
 #import "NSObject+WXSwizzle.h"
 #import "WXComponent+Events.h"
+#import "WXRecyclerDragController.h"
 
 static NSString * const kCollectionCellReuseIdentifier = @"WXRecyclerCell";
 static NSString * const kCollectionHeaderReuseIdentifier = @"WXRecyclerHeader";
@@ -43,12 +44,6 @@ typedef enum : NSUInteger {
     WXRecyclerLayoutTypeGrid,
 } WXRecyclerLayoutType;
 
-typedef enum : NSUInteger {
-    WXRecyclerDragTriggerNormal,
-    WXRecyclerDragTriggerPan
-} WXRecyclerDragTriggerType;
-
-
 @interface WXCollectionView : UICollectionView
 
 @end
@@ -91,20 +86,12 @@ typedef enum : NSUInteger {
 
 @end
 
-@interface WXRecyclerComponent () <UICollectionViewDataSource, UICollectionViewDelegate, WXMultiColumnLayoutDelegate, WXRecyclerUpdateControllerDelegate, WXCellRenderDelegate, WXHeaderRenderDelegate>
+@interface WXRecyclerComponent () <UICollectionViewDataSource, UICollectionViewDelegate, WXMultiColumnLayoutDelegate, WXRecyclerUpdateControllerDelegate, WXCellRenderDelegate, WXHeaderRenderDelegate, WXRecyclerDragControllerDelegate>
 
 @property (nonatomic, strong, readonly) WXRecyclerDataController *dataController;
 @property (nonatomic, strong, readonly) WXRecyclerUpdateController *updateController;
 @property (nonatomic, weak, readonly) UICollectionView *collectionView;
-@property (nonatomic, strong) UILongPressGestureRecognizer *currentLongPress;
-@property (nonatomic, strong) NSIndexPath  *startIndexPath;
-@property (nonatomic, strong) NSIndexPath  *dragingIndexPath;
-@property (nonatomic, strong) NSIndexPath  *targetIndexPath;
-@property (nonatomic, strong) NSMutableArray *excludedAry;
-@property (nonatomic, strong) UICollectionViewCell *dragingCell;
-@property (nonatomic, assign) BOOL isDragable;
-@property (nonatomic, assign) BOOL isDragAnchor;
-@property (nonatomic, assign) WXRecyclerDragTriggerType dragTriggerType;
+@property (nonatomic, strong) WXRecyclerDragController *dragController;
 
 @end
 
@@ -122,14 +109,6 @@ typedef enum : NSUInteger {
     if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) {
         [self _fillPadding];
         
-        if ([attributes[@"draggable"] boolValue]) {
-            if([attributes[@"dragTriggerType"]  isEqual: @"pan"]){
-                _dragTriggerType = WXRecyclerDragTriggerPan;
-            }
-            _isDragable = YES;
-        }else{
-            _isDragable = NO;
-        }
         
         if ([type isEqualToString:@"waterfall"] || (attributes[@"layout"] && [attributes[@"layout"] isEqualToString:@"multi-column"])) {
             // TODO: abstraction
@@ -150,6 +129,17 @@ typedef enum : NSUInteger {
         _updateController = [WXRecyclerUpdateController new];
         _updateController.delegate = self;
         [self fixFlicker];
+        
+        _dragController = [WXRecyclerDragController new];
+        _dragController.delegate = self;
+        if ([attributes[@"draggable"] boolValue]) {
+            if([attributes[@"dragTriggerType"]  isEqual: @"pan"]){
+                _dragController.dragTriggerType = WXRecyclerDragTriggerPan;
+            }
+            _dragController.isDragable = YES;
+        }else{
+            _dragController.isDragable = NO;
+        }
     }
     
     return self;
@@ -181,20 +171,8 @@ typedef enum : NSUInteger {
     [_collectionView registerClass:[WXCollectionViewCell class] forCellWithReuseIdentifier:kCollectionCellReuseIdentifier];
     [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:kCollectionSupplementaryViewKindHeader withReuseIdentifier:kCollectionHeaderReuseIdentifier];
     
-    _isDragAnchor = NO;
-    
-    _excludedAry = [[NSMutableArray alloc] init];
-    [_collectionView registerClass:[WXCollectionViewCell class] forCellWithReuseIdentifier:kCollectionCellReuseIdentifier];
-    [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:kCollectionSupplementaryViewKindHeader withReuseIdentifier:kCollectionHeaderReuseIdentifier];
-    
-    _currentLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
-    _currentLongPress.minimumPressDuration = 0.3f;
-    [_collectionView addGestureRecognizer:_currentLongPress];
-    
-    _dragingCell = [[WXCollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100/2.0f)];
-    _dragingCell.hidden = true;
-    [_collectionView addSubview:_dragingCell];
-    
+    _dragController.dragingCell = [[WXCollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100/2.0f)];
+    _dragController.collectionView = _collectionView;
     
     [self performUpdatesWithCompletion:^(BOOL finished) {
         
@@ -220,11 +198,11 @@ typedef enum : NSUInteger {
         
         if ([attributes[@"draggable"] boolValue]) {
             if([attributes[@"dragTriggerType"]  isEqual: @"pan"]){
-                _dragTriggerType = WXRecyclerDragTriggerPan;
+                _dragController.dragTriggerType = WXRecyclerDragTriggerPan;
             }
-            _isDragable = YES;
+            _dragController.isDragable = YES;
         }else{
-            _isDragable = NO;
+            _dragController.isDragable = NO;
         }
         
         if (attributes[@"columnWidth"]) {
@@ -403,7 +381,7 @@ typedef enum : NSUInteger {
     
     cellView.wx_component = contentView.wx_component;
     
-    [self goThroughAnchor:cellView.wx_component indexPath:indexPath];
+    [self.dragController goThroughAnchor:cellView.wx_component indexPath:indexPath];
     
     if (contentView.superview == cellView.contentView) {
         return cellView;
@@ -707,164 +685,20 @@ typedef enum : NSUInteger {
     });
 }
 
-#pragma mark - dragMethod
-- (void)longPressMethod:(UILongPressGestureRecognizer*)gesture
-{
-    if (_isDragable) {
-        switch (gesture.state) {
-            case UIGestureRecognizerStateBegan:
-                [self dragBegin:gesture];
-                break;
-            case UIGestureRecognizerStateChanged:
-                [self dragChanged:gesture];
-                break;
-            case UIGestureRecognizerStateEnded:
-                [self dragEnd:gesture];
-                break;
-            default:
-                break;
-        }
-    }
-}
+#define mark dragControllerDelegate
 
-- (void)dragBegin:(UILongPressGestureRecognizer *)gesture{
-    
-    CGPoint point = [gesture locationInView:_collectionView];
-    
-    _startIndexPath = [self getDragingIndexPathWithPoint:point];
-    if (!_startIndexPath) {
-        return;
+- (void)updateDataSource{
+    NSMutableArray *oldComponents = [[NSMutableArray alloc] initWithArray:self.dataController.sections[self.dragController.startIndexPath.section].cellComponents];
+    if(oldComponents.count > 1){
+        WXCellComponent *startComponent = self.dataController.sections[self.dragController.startIndexPath.section].cellComponents[self.dragController.startIndexPath.item];
+        [oldComponents removeObject:startComponent];
+        [oldComponents insertObject:startComponent atIndex:self.dragController.targetIndexPath.item];
+        self.dataController.sections[self.dragController.startIndexPath.section].cellComponents = oldComponents;
     }
-    
-    [self fireEvent:@"dragstart" params:@{@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
-    
-    _dragingIndexPath = [self getDragingIndexPathWithPoint:point];
-    if (!_dragingIndexPath) {
-        return;
-    }
-    
-    [_collectionView bringSubviewToFront:_dragingCell];
-    _dragingCell.frame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
-    _dragingCell.hidden = false;
-    [UIView animateWithDuration:0.3 animations:^{
-        [_dragingCell setTransform:CGAffineTransformMakeScale(1.2, 1.2)];
-    }];
 }
 
-- (void)dragChanged:(UILongPressGestureRecognizer *)gesture{
-    
-    if (!_startIndexPath) {
-        return;
-    }
-    CGPoint point = [gesture locationInView:_collectionView];
-    _dragingCell.center = point;
-    _targetIndexPath = [self getTargetIndexPathWithPoint:point];
-    
-    if (_targetIndexPath && _dragingIndexPath && (_targetIndexPath.section == _startIndexPath.section)){
-        [_collectionView moveItemAtIndexPath:_dragingIndexPath toIndexPath:_targetIndexPath];
-        _dragingIndexPath = _targetIndexPath;
-    }
-}
-
-- (void)dragEnd:(UILongPressGestureRecognizer *)gesture{
-    
-    if (!_startIndexPath || !_dragingIndexPath) {
-        return;
-    }
-    
-    [self fireEvent:@"dragend" params:@{@"toIndex":[NSString stringWithFormat:@"%ld",(long)_dragingIndexPath.row],@"fromIndex":[NSString stringWithFormat:@"%ld",(long)_startIndexPath.row]}];
-    
-    CGRect endFrame = [_collectionView cellForItemAtIndexPath:_dragingIndexPath].frame;
-    
-    __weak typeof(self) weakSelf = self;
-    [UIView animateWithDuration:0.3 animations:^{
-        [weakSelf.dragingCell setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
-        weakSelf.dragingCell.frame = endFrame;
-    } completion:^(BOOL finished) {
-        weakSelf.dragingCell.hidden = YES;
-        NSMutableArray *oldComponents = [[NSMutableArray alloc] initWithArray:weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents];
-        if(oldComponents.count > 1){
-            WXCellComponent *startComponent = weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents[weakSelf.startIndexPath.item];
-            [oldComponents removeObject:startComponent];
-            [oldComponents insertObject:startComponent atIndex:weakSelf.targetIndexPath.item];
-            weakSelf.dataController.sections[weakSelf.startIndexPath.section].cellComponents = oldComponents;
-        }
-    }];
-}
-
-- (NSIndexPath *)getDragingIndexPathWithPoint:(CGPoint)point{
-    NSIndexPath *dragingIndexPath = nil;
-    for (NSIndexPath *indexPath in [_collectionView indexPathsForVisibleItems]){
-        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame,point)) {
-            dragingIndexPath = indexPath;
-            break;
-        }
-    }
-    
-    BOOL isExcluded = NO;
-    if (dragingIndexPath) {
-        for (NSIndexPath *indexPath in _excludedAry) {
-            if (indexPath.row == dragingIndexPath.row) {
-                isExcluded = YES;
-            }
-        }
-    }
-    return isExcluded?nil:dragingIndexPath;
-}
-
-- (NSIndexPath *)getTargetIndexPathWithPoint:(CGPoint)point{
-    NSIndexPath *targetIndexPath = nil;
-    for (NSIndexPath *indexPath in _collectionView.indexPathsForVisibleItems) {
-        if (CGRectContainsPoint([_collectionView cellForItemAtIndexPath:indexPath].frame, point)) {
-            targetIndexPath = indexPath;
-        }
-    }
-    return targetIndexPath;
-}
-
-
-- (void)goThroughAnchor:(WXComponent *)wxComponent indexPath:(NSIndexPath *)indexPath{
-    if (wxComponent.attributes && [wxComponent.attributes[@"dragExcluded"] boolValue]){
-        [_excludedAry addObject:indexPath];
-        NSSet *set = [NSSet setWithArray:_excludedAry];
-        [_excludedAry removeAllObjects];
-        [_excludedAry addObjectsFromArray:[set allObjects]];
-    }
-    
-    //遍历获取锚点
-    NSMutableArray *subviewComponents = [[NSMutableArray alloc] init];
-    [subviewComponents addObjectsFromArray:wxComponent.subcomponents];
-    WXComponent *anchorComponent;
-    for (int i = 0 ; i < subviewComponents.count ; i++){
-        WXComponent *compoent = subviewComponents[i];
-        if (compoent.attributes[@"dragAnchor"]) {
-            anchorComponent = compoent;
-            _isDragAnchor = YES;
-            break;
-        }
-        
-        if (compoent.subcomponents && compoent.subcomponents.count && compoent.subcomponents.count > 0) {
-            [subviewComponents addObjectsFromArray:compoent.subcomponents];
-        }
-    }
-    
-    if (anchorComponent) {
-        //去除全局UILongPressGestureRecognizer手势
-        if (_currentLongPress) {
-            [self.collectionView removeGestureRecognizer:_currentLongPress];
-            _currentLongPress = nil;
-        }
-        
-        //添加锚点的手势
-        if (_dragTriggerType == WXRecyclerDragTriggerPan) {
-            UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
-            [anchorComponent.view addGestureRecognizer:panGestureRecognizer];
-            
-        }else{
-            UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressMethod:)];
-            [anchorComponent.view addGestureRecognizer:longPressGestureRecognizer];
-        }
-    }
+- (void)dragFireEvent:(NSString *)eventName params:(NSDictionary *)params{
+    [self fireEvent:eventName params:params];
 }
 
 - (void)fixedFlickerSelector


[3/6] incubator-weex git commit: Merge branch '0.16-dev' of https://github.com/apache/incubator-weex into dev_recycle_drag

Posted by cx...@apache.org.
Merge branch '0.16-dev' of https://github.com/apache/incubator-weex into dev_recycle_drag


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/62c12709
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/62c12709
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/62c12709

Branch: refs/heads/0.16-dev
Commit: 62c12709c603f34ee6cf43381d60712fad02b521
Parents: 8241639 5951404
Author: ximu <xi...@alibaba-inc.com>
Authored: Tue Aug 1 10:58:54 2017 +0800
Committer: ximu <xi...@alibaba-inc.com>
Committed: Tue Aug 1 10:58:54 2017 +0800

----------------------------------------------------------------------
 .gitignore                                      |   3 +
 WeexSDK.podspec                                 |   2 +-
 .../java/com/taobao/weex/WXSDKInstance.java     |  11 +-
 .../ui/component/list/BasicListComponent.java   |  15 +-
 build/build.js                                  | 105 +++-
 build/config.js                                 |  37 +-
 dangerfile.js                                   |  87 ++-
 entry.js                                        |  11 +
 examples/vue/index.vue                          |   1 +
 examples/vue/modules/picker.vue                 |  97 ++++
 html5/render/vue/README.md                      |  77 +++
 html5/render/vue/components/a.js                |  90 +--
 html5/render/vue/components/div.js              |  43 +-
 html5/render/vue/components/image.js            |  18 +-
 html5/render/vue/components/index.js            |  37 +-
 html5/render/vue/components/input.js            | 130 +++--
 html5/render/vue/components/scrollable/cell.js  |  39 ++
 .../render/vue/components/scrollable/header.js  | 102 ++--
 html5/render/vue/components/scrollable/index.js |  48 ++
 html5/render/vue/components/scrollable/list.js  |  82 +++
 .../vue/components/scrollable/list/cell.js      |  36 --
 .../vue/components/scrollable/list/index.js     |  77 ---
 .../vue/components/scrollable/list/listMixin.js |  47 --
 .../vue/components/scrollable/list/style.js     |  34 --
 .../components/scrollable/loading-indicator.js  |  17 +-
 .../render/vue/components/scrollable/loading.js | 141 ++---
 .../vue/components/scrollable/mixins/index.js   |  26 +
 .../vue/components/scrollable/mixins/list.js    |  46 ++
 .../components/scrollable/mixins/scrollable.js  | 267 +++++++++
 .../render/vue/components/scrollable/refresh.js | 157 ++---
 .../vue/components/scrollable/scroller.js       | 135 +++--
 .../render/vue/components/scrollable/style.css  |  85 +++
 .../vue/components/scrollable/waterfall.js      | 573 ++++++++++---------
 html5/render/vue/components/slider/index.js     |  52 +-
 html5/render/vue/components/slider/indicator.js |  18 +-
 .../render/vue/components/slider/slideMixin.js  |  46 +-
 .../vue/components/slider/slider-neighbor.js    |  12 +-
 html5/render/vue/components/slider/slider.css   |  19 +
 html5/render/vue/components/slider/slider.js    |  75 +++
 html5/render/vue/components/switch.js           | 114 ++--
 html5/render/vue/components/text.js             |  52 +-
 html5/render/vue/components/textarea.js         | 104 ++--
 html5/render/vue/components/video.js            | 107 ++--
 html5/render/vue/components/web.js              |  98 ++--
 html5/render/vue/core/style.js                  |  35 --
 html5/render/vue/env/global.js                  |   6 +
 html5/render/vue/env/index.js                   |   5 -
 html5/render/vue/index.js                       |  25 -
 html5/render/vue/mixins/base.js                 |  71 ---
 html5/render/vue/mixins/index.js                |   2 -
 html5/render/vue/mixins/scrollable.js           | 233 --------
 html5/render/vue/mixins/style.js                |   4 +-
 html5/render/vue/modules/animation.js           |  36 +-
 html5/render/vue/modules/dom.js                 |  21 +-
 html5/render/vue/modules/globalEvent.js         |   8 +-
 html5/render/vue/modules/index.js               |  36 +-
 html5/render/vue/modules/navigator.js           |  10 +-
 html5/render/vue/modules/webview.js             |  18 +-
 html5/render/vue/styles/base.css                |  86 +--
 html5/render/vue/styles/reset.css               |  19 +
 html5/render/vue/utils/lazyload.js              |  24 +-
 html5/render/vue/utils/perf.js                  | 283 +--------
 html5/test/render/vue/components/list.js        |   2 +-
 html5/test/render/vue/components/switch.js      |   5 +-
 html5/test/render/vue/core/node.js              |   5 +-
 .../render/vue/data/dotvue/event-bubble-bar.vue |   8 +-
 .../render/vue/data/dotvue/event-bubble.vue     |   4 +-
 html5/test/render/vue/examples/list-cell.js     |   2 +-
 html5/test/render/vue/helper/index.js           |   2 +-
 html5/test/render/vue/helper/main.js            |   3 +-
 html5/test/render/vue/helper/utils.js           |   4 +
 html5/test/render/vue/modules/animation.js      |  61 ++
 html5/test/render/vue/modules/dom.js            | 111 ++++
 html5/test/render/vue/modules/globalEvent.js    |  47 ++
 html5/test/render/vue/modules/navigator.js      |  46 ++
 html5/test/render/vue/modules/webview.js        |  55 ++
 html5/test/render/vue/utils/lazyload.js         |  59 +-
 html5/test/render/vue/utils/perf.js             |  94 +--
 html5/test/render/vue/utils/style.js            |  50 +-
 ios/playground/Podfile                          |   2 +-
 ios/playground/WeexDemo/Info.plist              |   4 +
 ios/playground/WeexDemo/WXDemoViewController.m  |   1 -
 ios/sdk/WeexSDK.xcodeproj/project.pbxproj       |   6 +-
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    |  27 +-
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m |  14 +
 ios/sdk/WeexSDK/Sources/Bridge/WXModuleMethod.h |   2 +
 ios/sdk/WeexSDK/Sources/Bridge/WXModuleMethod.m |  11 +-
 .../Sources/Component/WXImageComponent.m        |  89 ++-
 .../WeexSDK/Sources/Component/WXListComponent.m |   2 +-
 .../Sources/Manager/WXComponentManager.m        |  14 +-
 .../WeexSDK/Sources/Manager/WXTracingManager.h  |  35 +-
 .../WeexSDK/Sources/Manager/WXTracingManager.m  |  18 +-
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m   |   6 +-
 .../WeexSDK/Sources/Module/WXWebSocketModule.h  |   1 -
 .../WeexSDK/Sources/Module/WXWebSocketModule.m  |   1 +
 .../WeexSDK/Sources/Protocol/WXBridgeProtocol.h |   5 +
 .../Sources/Protocol/WXValidateProtocol.h       |   4 +-
 ios/sdk/WeexSDK/Sources/Utility/WXDefine.h      |   2 +-
 ios/sdk/WeexSDK/Sources/Utility/WXLog.m         |   9 +-
 ios/sdk/WeexSDK/Sources/WeexSDK.h               |   2 +-
 package.json                                    |  19 +-
 packages/weex-vue-plugins/weex-vue-a/README.md  |   3 +
 .../weex-vue-plugins/weex-vue-a/package.json    |  26 +
 .../weex-vue-plugins/weex-vue-a/src/index.js    |   2 +
 .../weex-vue-animation/README.md                |   3 +
 .../weex-vue-animation/package.json             |  27 +
 .../weex-vue-animation/src/index.js             |   2 +
 .../weex-vue-clipboard/README.md                |   3 +
 .../weex-vue-clipboard/package.json             |  27 +
 .../weex-vue-clipboard/src/index.js             |   2 +
 .../weex-vue-plugins/weex-vue-dom/README.md     |   3 +
 .../weex-vue-plugins/weex-vue-dom/package.json  |  27 +
 .../weex-vue-plugins/weex-vue-dom/src/index.js  |   2 +
 .../weex-vue-plugins/weex-vue-event/README.md   |   3 +
 .../weex-vue-event/package.json                 |  27 +
 .../weex-vue-event/src/index.js                 |   2 +
 .../weex-vue-geolocation/README.md              |   3 +
 .../weex-vue-geolocation/package.json           |  27 +
 .../weex-vue-geolocation/src/index.js           |   2 +
 .../weex-vue-global-event/README.md             |   3 +
 .../weex-vue-global-event/package.json          |  27 +
 .../weex-vue-global-event/src/index.js          |   2 +
 .../weex-vue-plugins/weex-vue-input/README.md   |   3 +
 .../weex-vue-input/package.json                 |  26 +
 .../weex-vue-input/src/index.js                 |   2 +
 .../weex-vue-plugins/weex-vue-modal/README.md   |   3 +
 .../weex-vue-modal/package.json                 |  27 +
 .../weex-vue-modal/src/index.js                 |   2 +
 .../weex-vue-navigator/README.md                |   3 +
 .../weex-vue-navigator/package.json             |  27 +
 .../weex-vue-navigator/src/index.js             |   2 +
 .../weex-vue-plugins/weex-vue-slider/README.md  |   3 +
 .../weex-vue-slider/package.json                |  27 +
 .../weex-vue-slider/src/index.js                |   2 +
 .../weex-vue-plugins/weex-vue-storage/README.md |   3 +
 .../weex-vue-storage/package.json               |  27 +
 .../weex-vue-storage/src/index.js               |   2 +
 .../weex-vue-plugins/weex-vue-stream/README.md  |   3 +
 .../weex-vue-stream/package.json                |  27 +
 .../weex-vue-stream/src/index.js                |   2 +
 .../weex-vue-plugins/weex-vue-switch/README.md  |   3 +
 .../weex-vue-switch/package.json                |  26 +
 .../weex-vue-switch/src/index.js                |   2 +
 .../weex-vue-textarea/.DS_Store                 | Bin 0 -> 6148 bytes
 .../weex-vue-textarea/README.md                 |   3 +
 .../weex-vue-textarea/package.json              |  26 +
 .../weex-vue-textarea/src/index.js              |   2 +
 .../weex-vue-plugins/weex-vue-video/README.md   |   3 +
 .../weex-vue-video/package.json                 |  26 +
 .../weex-vue-video/src/index.js                 |   2 +
 .../weex-vue-plugins/weex-vue-web/README.md     |   3 +
 .../weex-vue-plugins/weex-vue-web/package.json  |  26 +
 .../weex-vue-plugins/weex-vue-web/src/index.js  |   2 +
 .../weex-vue-websocket/README.md                |   3 +
 .../weex-vue-websocket/package.json             |  27 +
 .../weex-vue-websocket/src/index.js             |   2 +
 .../weex-vue-plugins/weex-vue-webview/README.md |   3 +
 .../weex-vue-webview/package.json               |  27 +
 .../weex-vue-webview/src/index.js               |   2 +
 packages/weex-vue-render/README.md              |  77 +++
 packages/weex-vue-render/package.json           |   9 +-
 packages/weex-vue-render/src/index.core.js      |  13 +
 packages/weex-vue-render/src/index.js           |  12 +
 pre-build/native-bundle-main.js                 |  12 +-
 scripts/dist-vue.sh                             |   2 +-
 test/pages/image-onload.vue                     |  14 +-
 test/scripts/components/image-onload.test.js    |  10 +
 vue.html                                        |   8 +-
 168 files changed, 3639 insertions(+), 2247 deletions(-)
----------------------------------------------------------------------