horizontal scroll in datagrid #113

This commit is contained in:
Jan Prochazka
2021-05-16 14:21:36 +02:00
parent 91741655b7
commit be053acf3c

View File

@@ -171,6 +171,7 @@
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">
@@ -663,23 +664,42 @@
} }
function handleGridWheel(event) { function handleGridWheel(event) {
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex; if (event.shiftKey) {
if (event.deltaY > 0) { let newFirstVisibleColumnScrollIndex = firstVisibleColumnScrollIndex;
newFirstVisibleRowScrollIndex += wheelRowCount; if (event.deltaY > 0) {
} newFirstVisibleColumnScrollIndex++;
if (event.deltaY < 0) { }
newFirstVisibleRowScrollIndex -= wheelRowCount; if (event.deltaY < 0) {
} newFirstVisibleColumnScrollIndex--;
let rowCount = grider.rowCount; }
if (newFirstVisibleRowScrollIndex + visibleRowCountLowerBound > rowCount) { if (newFirstVisibleColumnScrollIndex > maxScrollColumn) {
newFirstVisibleRowScrollIndex = rowCount - visibleRowCountLowerBound + 1; newFirstVisibleColumnScrollIndex = maxScrollColumn;
} }
if (newFirstVisibleRowScrollIndex < 0) { if (newFirstVisibleColumnScrollIndex < 0) {
newFirstVisibleRowScrollIndex = 0; newFirstVisibleColumnScrollIndex = 0;
} }
firstVisibleRowScrollIndex = newFirstVisibleRowScrollIndex; firstVisibleColumnScrollIndex = newFirstVisibleColumnScrollIndex;
domVerticalScroll.scroll(newFirstVisibleRowScrollIndex); domHorizontalScroll.scroll(newFirstVisibleColumnScrollIndex);
} else {
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex;
if (event.deltaY > 0) {
newFirstVisibleRowScrollIndex += wheelRowCount;
}
if (event.deltaY < 0) {
newFirstVisibleRowScrollIndex -= wheelRowCount;
}
let rowCount = grider.rowCount;
if (newFirstVisibleRowScrollIndex + visibleRowCountLowerBound > rowCount) {
newFirstVisibleRowScrollIndex = rowCount - visibleRowCountLowerBound + 1;
}
if (newFirstVisibleRowScrollIndex < 0) {
newFirstVisibleRowScrollIndex = 0;
}
firstVisibleRowScrollIndex = newFirstVisibleRowScrollIndex;
domVerticalScroll.scroll(newFirstVisibleRowScrollIndex);
}
} }
function getSelectedRowIndexes() { function getSelectedRowIndexes() {
@@ -958,6 +978,7 @@
); );
const menu = getContextMenu(); const menu = getContextMenu();
</script> </script>
{#if !display || (!isDynamicStructure && (!columns || columns.length == 0))} {#if !display || (!isDynamicStructure && (!columns || columns.length == 0))}
@@ -1164,4 +1185,5 @@
right: 40px; right: 40px;
bottom: 20px; bottom: 20px;
} }
</style> </style>