拖拽

image.png
优化,减少 dom 层级。
富dom操作,直接操作dom
image.png
image.png
拖拽状态管理
renderprops状态容器:
区分 Drop物体 和 Drag物体

  1. const DropContainer = ({ children }) => {
  2. const handleDragEnter = (e) => {
  3. e.preventDefault();
  4. e.stopPropagation();
  5. };
  6. const handleDragLeave = (e) => {
  7. console.log('on Drop leave');
  8. e.preventDefault();
  9. e.stopPropagation();
  10. };
  11. const handleDragOver = (e) => {
  12. e.preventDefault();
  13. e.stopPropagation();
  14. };
  15. const handleDrop = (e) => {
  16. console.log('on Drop');
  17. e.preventDefault();
  18. e.stopPropagation();
  19. };
  20. return children({
  21. onDragEnter: handleDragEnter,
  22. onDragLeave: handleDragLeave,
  23. onDragOver: handleDragOver,
  24. onDrop: handleDrop,
  25. });
  26. };
  27. const DragContainer = ({ children }) => {
  28. const handleDragStart = (e) => {
  29. e.preventDefault();
  30. e.stopPropagation();
  31. };
  32. const handleDrag = (e: DragEvent) => {
  33. e.preventDefault();
  34. e.stopPropagation();
  35. };
  36. const handleDragEnd = (e) => {
  37. e.preventDefault();
  38. e.stopPropagation();
  39. };
  40. return children({
  41. onDragStart: handleDragStart,
  42. onDrag: handleDrag,
  43. onDragEnd: handleDragEnd,
  44. });
  45. };

自动化测试

Electron + Puppeteer + Robotjs 实现工作自动化 - 凌霄光的文章 - 知乎 https://zhuanlan.zhihu.com/p/197737856

image.png
https://github.com/tinytacoteam/zazu/blob/e6e37e63841ca4e8abd6bd6dfc7d211ae30d18d5/features/step_definitions/myStepDefinitions.js#L91

react 事件:onXxCapture

不加代表冒泡阶段触发,加代表捕获阶段触发
image.png