From ef4eb4d5172e0b9154f80906901c60f692a89bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Thu, 1 Sep 2022 10:19:18 +0800 Subject: [PATCH] iOS: update horizontal list beforeDragging & add itemCanDrag --- doric-demo/src/HorizontalListDemo.ts | 14 ++++- .../Classes/Shader/DoricHorizontalListNode.m | 60 +++++++++++++++---- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/doric-demo/src/HorizontalListDemo.ts b/doric-demo/src/HorizontalListDemo.ts index 48d6006b..8b01d942 100644 --- a/doric-demo/src/HorizontalListDemo.ts +++ b/doric-demo/src/HorizontalListDemo.ts @@ -66,11 +66,21 @@ class ListVM extends ViewModel { onAttached(state: ListModel, vh: ListVH) { vh.list.apply({ canDrag: true, + itemCanDrag: (from) => { + if (from === 0) { + return false; + } else { + return true; + } + }, + beforeDragging: (from) => { + return [0, 1, 2] + }, onDragging: (from, to) => { - log(`onDragging, from: ${from}, to: ${to}`) + loge(`onDragging from: ${from}, to: ${to}`) }, onDragged: (from, to) => { - log(`onDragged, from: ${from}, to: ${to}`) + loge(`onDragged from: ${from}, to: ${to}`) }, renderItem: (index) => { const data = state.data[index] diff --git a/doric-iOS/Pod/Classes/Shader/DoricHorizontalListNode.m b/doric-iOS/Pod/Classes/Shader/DoricHorizontalListNode.m index 5f5165f7..2ea74c34 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricHorizontalListNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricHorizontalListNode.m @@ -72,11 +72,12 @@ @interface DoricHorizontalListNode () *)didScrollBlocks { if (!_didScrollBlocks) { _didScrollBlocks = [NSMutableSet new]; @@ -549,6 +584,7 @@ - (void)reset { self.loadMoreViewId = nil; self.onScrollFuncId = nil; self.onScrollEndFuncId = nil; + self.itemCanDragFuncId = nil; self.beforeDraggingFuncId = nil; self.onDraggingFuncId = nil; self.onDraggedFuncId = nil;