Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
之前存在问题是,列表中的头像本身是一个链接,既可以点击打开相应用户的个人页面也可以拖拽排序。但是后者监听的
mousedown
事件会和前者的click
事件冲突。我们使用的 react-sortable-hoc 模块给出了三种解决方案。
distance
参数和pressDelay
参数两种方案体验都不是很好,拖拽响应比较慢。而第三种使用SortableHandle
的方案,因为拖拽和点击区域可以分开,因此不存在上述问题,但是需要专门设计SortableHandle
(即表示“可拖拽”的元素)的样式。于是参考这篇文章设计了拖拽排序用户体验,最终采用了类似 Gmail 的设计。当鼠标指针放到头像上时,头像上方显示一片点状图案提示用户,用户按住这块区域可以拖拽。注意鼠标指针的变化。
但是目前仍然存在一些问题:
cursor: grabbing
),尝试了多种办法都还是没能解决。现在的实际情况为,用户释放拖拽的一瞬间,指针会变成攥住的样式,然后马上恢复普通状态。这个很怪异,猜测可能是 Chrome 的 bug,和pointer-events
有关系。(即便上图里,指针变化也是有延时的,有点不正常)lockToContainerEdges
参数现在没有效果。这几个问题基本上不影响用户使用,留待以后解决。