mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-03 16:48:38 -04:00
Minor.
This commit is contained in:
parent
07ccdbd734
commit
4a3e8c6734
2 changed files with 6 additions and 5 deletions
|
@ -11,7 +11,6 @@
|
||||||
"url": "https://github.com/lrsjng/h5ai.git"
|
"url": "https://github.com/lrsjng/h5ai.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
|
||||||
"build": "node ghu release"
|
"build": "node ghu release"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -41,7 +41,7 @@ const elRect = el => {
|
||||||
return {l: rect.left, t: rect.top, r: rect.right, b: rect.bottom};
|
return {l: rect.left, t: rect.top, r: rect.right, b: rect.bottom};
|
||||||
};
|
};
|
||||||
|
|
||||||
const rectEqual = (r1, r2) => {
|
const rectsAreEqual = (r1, r2) => {
|
||||||
return !!r1 && !!r2 &&
|
return !!r1 && !!r2 &&
|
||||||
r1.l === r2.l &&
|
r1.l === r2.l &&
|
||||||
r1.t === r2.t &&
|
r1.t === r2.t &&
|
||||||
|
@ -51,14 +51,14 @@ const rectEqual = (r1, r2) => {
|
||||||
|
|
||||||
const updateRects = $items => {
|
const updateRects = $items => {
|
||||||
const el0 = $items[0];
|
const el0 = $items[0];
|
||||||
if (!rectEqual(elRect(el0), el0 && el0._rect)) {
|
if (!rectsAreEqual(elRect(el0), el0 && el0._rect)) {
|
||||||
$items.each(el => {
|
$items.each(el => {
|
||||||
el._rect = elRect(el);
|
el._rect = elRect(el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const doOverlap = (rect1, rect2) => {
|
const rectsDoOverlap = (rect1, rect2) => {
|
||||||
if (!rect1 || !rect2) {
|
if (!rect1 || !rect2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ const selectionUpdate = ev => {
|
||||||
updateRects($items);
|
updateRects($items);
|
||||||
|
|
||||||
$items.rmCls('selecting').each(el => {
|
$items.rmCls('selecting').each(el => {
|
||||||
if (doOverlap(selRect, el._rect)) {
|
if (rectsDoOverlap(selRect, el._rect)) {
|
||||||
dom(el).addCls('selecting');
|
dom(el).addCls('selecting');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -110,6 +110,7 @@ const selectionEnd = ev => {
|
||||||
.off('mousemove', selectionUpdate)
|
.off('mousemove', selectionUpdate)
|
||||||
.off('mouseup', selectionEnd);
|
.off('mouseup', selectionEnd);
|
||||||
|
|
||||||
|
selectionUpdate(ev);
|
||||||
dom('#items .item.selecting.selected').rmCls('selecting').rmCls('selected');
|
dom('#items .item.selecting.selected').rmCls('selecting').rmCls('selected');
|
||||||
dom('#items .item.selecting').rmCls('selecting').addCls('selected');
|
dom('#items .item.selecting').rmCls('selecting').addCls('selected');
|
||||||
publish();
|
publish();
|
||||||
|
@ -134,6 +135,7 @@ const selectionStart = ev => {
|
||||||
.on('mousemove', selectionUpdate)
|
.on('mousemove', selectionUpdate)
|
||||||
.on('mouseup', selectionEnd);
|
.on('mouseup', selectionEnd);
|
||||||
|
|
||||||
|
selectionUpdate(ev);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue