mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
Merge pull request #152 from cschreier/master
#150 Enable horizontal scrolling with touchpad
This commit is contained in:
commit
86eca6bc7e
@ -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,43 +665,52 @@
|
|||||||
|
|
||||||
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) {
|
|
||||||
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 scrollVertical(deltaX, deltaY) {
|
||||||
|
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex;
|
||||||
|
if (deltaY > 0 && deltaX === -0) {
|
||||||
|
newFirstVisibleRowScrollIndex += wheelRowCount;
|
||||||
|
} else if (deltaY < 0 && deltaX === -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 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() {
|
||||||
if (selectedCells.find(x => x[0] == 'header')) return _.range(0, grider.rowCount);
|
if (selectedCells.find(x => x[0] == 'header')) return _.range(0, grider.rowCount);
|
||||||
return _.uniq((selectedCells || []).map(x => x[0])).filter(x => _.isNumber(x));
|
return _.uniq((selectedCells || []).map(x => x[0])).filter(x => _.isNumber(x));
|
||||||
@ -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))}
|
||||||
@ -1001,7 +1008,13 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="container" bind:clientWidth={containerWidth} bind:clientHeight={containerHeight} use:contextMenu={menu}>
|
<div
|
||||||
|
class="container"
|
||||||
|
bind:clientWidth={containerWidth}
|
||||||
|
bind:clientHeight={containerHeight}
|
||||||
|
use:contextMenu={menu}
|
||||||
|
on:wheel={handleGridWheel}
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="focus-field"
|
class="focus-field"
|
||||||
@ -1019,7 +1032,6 @@
|
|||||||
on:mousedown={handleGridMouseDown}
|
on:mousedown={handleGridMouseDown}
|
||||||
on:mousemove={handleGridMouseMove}
|
on:mousemove={handleGridMouseMove}
|
||||||
on:mouseup={handleGridMouseUp}
|
on:mouseup={handleGridMouseUp}
|
||||||
on:wheel={handleGridWheel}
|
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -1187,5 +1199,4 @@
|
|||||||
right: 40px;
|
right: 40px;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user