浏览代码

Allow changing opacity with scroll wheel (#662)

Bakhtiiar Muzakparov 5 年之前
父节点
当前提交
f955f58bc4
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      src/actions/actionProperties.tsx

+ 14 - 0
src/actions/actionProperties.tsx

@@ -220,6 +220,20 @@ export const actionChangeOpacity: Action = {
         max="100"
         max="100"
         step="10"
         step="10"
         onChange={e => updateData(+e.target.value)}
         onChange={e => updateData(+e.target.value)}
+        onWheel={e => {
+          e.stopPropagation();
+          const target = e.target as HTMLInputElement;
+          const STEP = 10;
+          const MAX = 100;
+          const MIN = 0;
+          const value = +target.value;
+
+          if (e.deltaY < 0 && value < MAX) {
+            updateData(value + STEP);
+          } else if (e.deltaY > 0 && value > MIN) {
+            updateData(value - STEP);
+          }
+        }}
         value={
         value={
           getFormValue(
           getFormValue(
             appState.editingElement,
             appState.editingElement,