refactor: renmae selectElementUUID

This commit is contained in:
chenshenhai 2021-07-24 09:38:21 +08:00
parent 82f7095ae8
commit 42f013d24e
4 changed files with 10 additions and 8 deletions

View file

@ -1,10 +1,12 @@
# @idraw/core
* [x] License text in JS result
* [x] Options default data
* [] Change idraw.selectElementByUUID to idraw.selectElementByIndex
* [] Change idraw.selectElement use uuid arg
* [] Support gradient color
* [] Listen keyboard action
* [] Keep all num two decimals
* [x] License text in JS result
* [x] Options default data
* [x] BUG: Select area calculate elements error
* [x] Move elements that in selected-area
* [x] Area select

View file

@ -37,7 +37,7 @@ function listenElements(core) {
const el = e.path[0];
if (el.hasAttribute('data-elem-name')) {
const uuid = el.getAttribute('data-elem-name');
core.selectElementByUUID(uuid);
core.selectElement(uuid);
} else if (el.hasAttribute('data-elem-btn-up')) {
const uuid = el.getAttribute('data-elem-btn-up');
core.moveUpElement(uuid);

View file

@ -99,7 +99,7 @@ class Core {
this.draw();
}
selectElement(index: number, opts?: { useMode?: boolean }): void {
selectElementByIndex(index: number, opts?: { useMode?: boolean }): void {
if (this[_onlyRender] === true) return;
if (this[_data].elements[index]) {
const uuid = this[_data].elements[index].uuid;
@ -114,11 +114,11 @@ class Core {
}
}
selectElementByUUID(uuid: string, opts?: { useMode?: boolean }): void {
selectElement(uuid: string, opts?: { useMode?: boolean }): void {
if (this[_onlyRender] === true) return;
const index = this[_helper].getElementIndexByUUID(uuid);
if (typeof index === 'number' && index >= 0) {
this.selectElement(index, opts);
this.selectElementByIndex(index, opts);
}
}
@ -278,7 +278,7 @@ class Core {
const [index, uuid] = this[_element].isPointInElement(point, this[_data]);
if (index >= 0) {
// Controll Element
this.selectElement(index, { useMode: true });
this.selectElementByIndex(index, { useMode: true });
if (typeof uuid === 'string' && this[_coreEvent].has('screenSelectElement')) {
this[_coreEvent].trigger(
'screenSelectElement',

View file

@ -36,7 +36,7 @@ function listenElements(idraw) {
const el = e.path[0];
if (el.hasAttribute('data-elem-name')) {
const uuid = el.getAttribute('data-elem-name');
idraw.selectElementByUUID(uuid);
idraw.selectElement(uuid);
} else if (el.hasAttribute('data-elem-btn-up')) {
const uuid = el.getAttribute('data-elem-btn-up');
idraw.moveUpElement(uuid);