mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-11-10 10:18:57 +03:00
chore: delay overlap dragtarget event
This commit is contained in:
parent
d941db29a1
commit
7be510fa22
@ -28,7 +28,7 @@ class Log {
|
|||||||
|
|
||||||
static void trace(String? message) {
|
static void trace(String? message) {
|
||||||
if (enableLog) {
|
if (enableLog) {
|
||||||
debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
|
// debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ class AFBoardDataController extends ChangeNotifier
|
|||||||
assert(index != -1);
|
assert(index != -1);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
if (index != newIndex) {
|
if (index != newIndex) {
|
||||||
Log.debug(
|
Log.trace(
|
||||||
'[$BoardPhantomController] update $columnId:$index to $columnId:$newIndex');
|
'[$BoardPhantomController] update $columnId:$index to $columnId:$newIndex');
|
||||||
final item = columnDataController.removeAt(index, notify: false);
|
final item = columnDataController.removeAt(index, notify: false);
|
||||||
columnDataController.insert(newIndex, item, notify: false);
|
columnDataController.insert(newIndex, item, notify: false);
|
||||||
|
@ -55,6 +55,7 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
|
|||||||
final String reorderFlexId;
|
final String reorderFlexId;
|
||||||
final List<String> acceptedReorderFlexId;
|
final List<String> acceptedReorderFlexId;
|
||||||
final OverlapDragTargetDelegate delegate;
|
final OverlapDragTargetDelegate delegate;
|
||||||
|
Timer? _delayOperation;
|
||||||
|
|
||||||
OverlappingDragTargetInterceptor({
|
OverlappingDragTargetInterceptor({
|
||||||
required this.delegate,
|
required this.delegate,
|
||||||
@ -77,12 +78,17 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
|
|||||||
if (dragTargetId == dragTargetData.reorderFlexId) {
|
if (dragTargetId == dragTargetData.reorderFlexId) {
|
||||||
delegate.cancel();
|
delegate.cancel();
|
||||||
} else {
|
} else {
|
||||||
final index = delegate.canMoveTo(dragTargetId);
|
/// The priority of the column interactions is high than the cross column.
|
||||||
Log.trace(
|
/// Workaround: delay 100 milliseconds to lower the cross column event priority.
|
||||||
'[$OverlappingDragTargetInterceptor] move to $dragTargetId at $index');
|
_delayOperation?.cancel();
|
||||||
if (index != -1) {
|
_delayOperation = Timer(const Duration(milliseconds: 100), () {
|
||||||
delegate.moveTo(dragTargetId, dragTargetData, index);
|
final index = delegate.canMoveTo(dragTargetId);
|
||||||
}
|
if (index != -1) {
|
||||||
|
Log.trace(
|
||||||
|
'[$OverlappingDragTargetInterceptor] move to $dragTargetId at $index');
|
||||||
|
delegate.moveTo(dragTargetId, dragTargetData, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -437,7 +437,7 @@ class ReorderFlexState extends State<ReorderFlex>
|
|||||||
/// The [willAccept] will be true if the dargTarget is the widget that gets
|
/// The [willAccept] will be true if the dargTarget is the widget that gets
|
||||||
/// dragged and it is dragged on top of the other dragTargets.
|
/// dragged and it is dragged on top of the other dragTargets.
|
||||||
///
|
///
|
||||||
Log.debug(
|
Log.trace(
|
||||||
'[$ReorderDragTarget] ${widget.dataSource.identifier} on will accept, dragIndex:$dragIndex, dragTargetIndex:$dragTargetIndex, count: ${widget.dataSource.items.length}');
|
'[$ReorderDragTarget] ${widget.dataSource.identifier} on will accept, dragIndex:$dragIndex, dragTargetIndex:$dragTargetIndex, count: ${widget.dataSource.items.length}');
|
||||||
|
|
||||||
bool willAccept =
|
bool willAccept =
|
||||||
|
Loading…
Reference in New Issue
Block a user