combiner fixes

This commit is contained in:
Mashy 2019-11-06 16:03:39 +10:00
parent b3ba8825e4
commit 4cc42e305c

View File

@ -296,29 +296,30 @@ class Vbox extends preact.Component {
} return false;
}) ? 'combo-border' : '';
function onClick(e) {
function onClick(type) {
if (vboxSelecting) clearVboxSelected();
if (reclaiming) return sendVboxReclaim(i);
const combinerContainsIndex = combiner.indexOf(i) > -1;
// 4 things selected
if (combiner.length > 2) {
if (combiner.length > 2 && !combinerContainsIndex) {
setInfo(vbox.bound[i]);
return combinerChange([i]);
}
// removing
const combinerIndex = combiner.indexOf(i);
if (combinerIndex > -1) {
if (combinerContainsIndex) {
if (type === 'click') {
return combinerChange(without(combiner, i));
}
return true;
// return combinerChange(without(combiner, i));
}
combiner.push(i);
if (!comboHighlight) {
if (!comboHighlight && !combinerContainsIndex) {
setInfo(vbox.bound[i]);
return combinerChange([i]);
}
combiner.push(i);
return combinerChange(combiner);
}
@ -332,17 +333,14 @@ class Vbox extends preact.Component {
<label
draggable='true'
onDragStart={ev => {
onClick(ev);
onClick('drag');
ev.dataTransfer.setData('text', '');
}}
onDragEnd={() => {
if (combiner.length === 1) combinerChange([]);
}}>
<button
class={classes}
onMouseOver={e => vboxHover(e, v)}
onClick={e => e.stopPropagation()}
onMouseDown={onClick}>
onMouseDown={() => onClick('click')}>
{invObject}
</button>
</label>