enable horizontal scroll with touchpad

This commit is contained in:
Christian Schreier
2021-07-31 12:35:48 +02:00
parent 32d05edb6a
commit 296038a3de

View File

@@ -171,7 +171,6 @@
if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value); if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value);
return value; return value;
} }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -666,30 +665,21 @@
function handleGridWheel(event) { function handleGridWheel(event) {
if (event.shiftKey) { if (event.shiftKey) {
let newFirstVisibleColumnScrollIndex = firstVisibleColumnScrollIndex; scrollHorizontal(event.deltaY, event.deltaX);
if (event.deltaY > 0) {
newFirstVisibleColumnScrollIndex++;
}
if (event.deltaY < 0) {
newFirstVisibleColumnScrollIndex--;
}
if (newFirstVisibleColumnScrollIndex > maxScrollColumn) {
newFirstVisibleColumnScrollIndex = maxScrollColumn;
}
if (newFirstVisibleColumnScrollIndex < 0) {
newFirstVisibleColumnScrollIndex = 0;
}
firstVisibleColumnScrollIndex = newFirstVisibleColumnScrollIndex;
domHorizontalScroll.scroll(newFirstVisibleColumnScrollIndex);
} else { } else {
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex; scrollHorizontal(event.deltaX, event.deltaY);
if (event.deltaY > 0) { scrollVertical(event.deltaX, event.deltaY);
newFirstVisibleRowScrollIndex += wheelRowCount;
} }
if (event.deltaY < 0) { }
function scrollVertical(deltaX, deltaY) {
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex;
if (deltaY > 0 && deltaX === -0) {
newFirstVisibleRowScrollIndex += wheelRowCount;
} else if (deltaY < 0 && deltaX === -0) {
newFirstVisibleRowScrollIndex -= wheelRowCount; newFirstVisibleRowScrollIndex -= wheelRowCount;
} }
let rowCount = grider.rowCount; let rowCount = grider.rowCount;
if (newFirstVisibleRowScrollIndex + visibleRowCountLowerBound > rowCount) { if (newFirstVisibleRowScrollIndex + visibleRowCountLowerBound > rowCount) {
newFirstVisibleRowScrollIndex = rowCount - visibleRowCountLowerBound + 1; newFirstVisibleRowScrollIndex = rowCount - visibleRowCountLowerBound + 1;
@@ -697,10 +687,28 @@
if (newFirstVisibleRowScrollIndex < 0) { if (newFirstVisibleRowScrollIndex < 0) {
newFirstVisibleRowScrollIndex = 0; newFirstVisibleRowScrollIndex = 0;
} }
firstVisibleRowScrollIndex = newFirstVisibleRowScrollIndex;
firstVisibleRowScrollIndex = newFirstVisibleRowScrollIndex;
domVerticalScroll.scroll(newFirstVisibleRowScrollIndex); domVerticalScroll.scroll(newFirstVisibleRowScrollIndex);
} }
function scrollHorizontal(deltaX, deltaY) {
let newFirstVisibleColumnScrollIndex = firstVisibleColumnScrollIndex;
if (deltaX > 0 && deltaY === -0) {
newFirstVisibleColumnScrollIndex++;
} else if (deltaX < 0 && deltaY === -0) {
newFirstVisibleColumnScrollIndex--;
}
if (newFirstVisibleColumnScrollIndex > maxScrollColumn) {
newFirstVisibleColumnScrollIndex = maxScrollColumn;
}
if (newFirstVisibleColumnScrollIndex < 0) {
newFirstVisibleColumnScrollIndex = 0;
}
firstVisibleColumnScrollIndex = newFirstVisibleColumnScrollIndex;
domHorizontalScroll.scroll(newFirstVisibleColumnScrollIndex);
} }
function getSelectedRowIndexes() { function getSelectedRowIndexes() {
@@ -980,7 +988,6 @@
); );
const menu = getContextMenu(); const menu = getContextMenu();
</script> </script>
{#if !display || (!isDynamicStructure && (!columns || columns.length == 0))} {#if !display || (!isDynamicStructure && (!columns || columns.length == 0))}
@@ -1187,5 +1194,4 @@
right: 40px; right: 40px;
bottom: 20px; bottom: 20px;
} }
</style> </style>