feat: wheel select

This commit is contained in:
cha0s 2021-07-09 15:48:21 -05:00
parent 53ee52dac8
commit 7dc8618761
2 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,7 @@ const Stage = forwardRef(({
'mouseout',
'mousedown',
'mouseup',
'wheel',
]
.map((event) => K.fromEvents(renderer.element, event)),
),

View File

@ -26,7 +26,13 @@ function EntitiesSide({
if (!events) {
return undefined;
}
const onValue = ({clientX, clientY, target, type}) => {
const onValue = ({
clientX,
clientY,
deltaY,
target,
type,
}) => {
const updatePosition = () => {
const {left, top} = target.getBoundingClientRect();
patch.diff(
@ -52,6 +58,12 @@ function EntitiesSide({
setIsHolding(false);
break;
}
case 'wheel': {
const {length} = resource.entities;
const inc = deltaY / Math.abs(deltaY);
setSelectedEntityIndex((selectedEntityIndex + length + inc) % length);
break;
}
default:
}
};