ly525 / luban-h5

[WIP]en: web design tool || mobile page builder/editor || mini webflow for mobile page. zh: 类似易企秀的H5制作、建站工具、可视化搭建系统.
https://ly525.gitee.io/luban-h5
GNU General Public License v3.0
6.09k stars 1.28k forks source link

添加为何添加 class 的原因:与 handleClickCanvas 配合 #47

Closed todo[bot] closed 4 years ago

todo[bot] commented 5 years ago

https://github.com/ly525/luban-h5/blob/eecd65504f53e3acb1c953c7aa4dcfce906364a8/front-end/h5/src/components/core/editor/canvas/edit.js#L24-L29


This issue was generated by todo based on a TODO comment in eecd65504f53e3acb1c953c7aa4dcfce906364a8. It's been assigned to @ly525 because they committed the code.
ly525 commented 4 years ago

https://github.com/ly525/luban-h5/blob/84a92f5c60628f9b3103301252b6bb1ba8dd72b2/front-end/h5/src/components/core/editor/canvas/edit.js#L126-L137

给在编辑模式下画布上的元素添加 class: 'element-on-edit-canvas 的原因

在右击画布上的时候(编辑模式),会显示右键菜单,如果右击的是画布上的某个元素(这一部分的判断就是通过 e.target.classList.contains('element-on-edit-canvas') 来实现的

  1. 只有编辑模式,才会给元素上添加 element-on-edit-canvas class
  2. 此外就是 如果是在 非画布画布上元素之间的空白区域右击,也是不会出现右键菜单的
可能这个 className 变成 element-with-context-menu 会更好理解