diff --git a/packages/core/__tests__/lib/core-is.test.ts b/packages/core/__tests__/lib/core-is.test.ts index df22c06..5310b19 100644 --- a/packages/core/__tests__/lib/core-is.test.ts +++ b/packages/core/__tests__/lib/core-is.test.ts @@ -1,6 +1,6 @@ import Core from './../../src'; -describe("@idraw/core static is", () => { +describe("@idraw/core:static is", () => { test('Core.is.number', () => { expect(Core.is.number(0)).toStrictEqual(true); diff --git a/packages/core/examples/features/css/index.css b/packages/core/examples/features/css/index.css index 5d0eaeb..b9f15ca 100644 --- a/packages/core/examples/features/css/index.css +++ b/packages/core/examples/features/css/index.css @@ -61,6 +61,7 @@ html, body { line-height: 30px; color: #666; font-size: 14px; + user-select: none; } .elem-item:last-child { diff --git a/packages/core/examples/features/lib/element.js b/packages/core/examples/features/lib/element.js index 686ad94..7263603 100644 --- a/packages/core/examples/features/lib/element.js +++ b/packages/core/examples/features/lib/element.js @@ -49,7 +49,21 @@ function listenElements(core) { renderElemens(core); } else if (el.hasAttribute('data-elem-btn-lock')) { const uuid = el.getAttribute('data-elem-btn-lock'); - core.moveDownElement(uuid); + const elem = core.getElement(uuid); + if (!elem.operation) { + elem.operation = {}; + } + elem.operation.lock = !elem.operation.lock; + core.updateElement(elem); + renderElemens(core); + } else if (el.hasAttribute('data-elem-btn-invisible')) { + const uuid = el.getAttribute('data-elem-btn-invisible'); + const elem = core.getElement(uuid); + if (!elem.operation) { + elem.operation = {}; + } + elem.operation.invisible = !elem.operation.invisible; + core.updateElement(elem); renderElemens(core); } }, true); diff --git a/packages/core/examples/features/lib/main.js b/packages/core/examples/features/lib/main.js index b040549..be08f5e 100644 --- a/packages/core/examples/features/lib/main.js +++ b/packages/core/examples/features/lib/main.js @@ -39,7 +39,7 @@ const core = new Core(mount, { }); -initEvent(); +// initEvent(); core.setData(data); @@ -85,4 +85,9 @@ function initEvent() { console.log('screenDoubleClickElement ===', p) }) -} \ No newline at end of file +} + +// TODO +core.on('screenDoubleClickElement', (p) => { + console.log('screenDoubleClickElement ===', p) +}) \ No newline at end of file diff --git a/packages/core/src/mixins/event.ts b/packages/core/src/mixins/event.ts index d62e6c8..7b9dd63 100644 --- a/packages/core/src/mixins/event.ts +++ b/packages/core/src/mixins/event.ts @@ -37,10 +37,13 @@ function handleDoubleClick(core: Core) { return function ( point: TypePoint) { const [index, uuid] = core[_element].isPointInElement(point, core[_data]); if (index >= 0 && uuid) { - core[_coreEvent].trigger( - 'screenDoubleClickElement', - { index, uuid, element: deepClone(core[_data].elements?.[index])} - ); + const elem = deepClone(core[_data].elements?.[index]); + if (elem?.operation?.invisible !== true) { + core[_coreEvent].trigger( + 'screenDoubleClickElement', + { index, uuid, element: deepClone(core[_data].elements?.[index])} + ); + } } core[_draw](); } @@ -90,7 +93,6 @@ function handlePoint(core: Core) { function handleClick(core: Core) { return function(point: TypePoint): void { - console.log('handleClick: point =', point) const [index, uuid] = core[_element].isPointInElement(point, core[_data]); if (index >= 0 && uuid) { core[_coreEvent].trigger(