mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 01:58:27 +00:00
fix: It can listen doubleClickElement when the element is invisible
This commit is contained in:
parent
27e26e5d86
commit
151fe71e95
5 changed files with 31 additions and 9 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ html, body {
|
|||
line-height: 30px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.elem-item:last-child {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const core = new Core(mount, {
|
|||
});
|
||||
|
||||
|
||||
initEvent();
|
||||
// initEvent();
|
||||
|
||||
core.setData(data);
|
||||
|
||||
|
|
@ -85,4 +85,9 @@ function initEvent() {
|
|||
console.log('screenDoubleClickElement ===', p)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
core.on('screenDoubleClickElement', (p) => {
|
||||
console.log('screenDoubleClickElement ===', p)
|
||||
})
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue