|
|
@ -108,8 +108,9 @@ export class FileGridComponent implements OnChanges, OnInit {
|
|
|
|
const entries = this.gridEntries.slice(i * this.columns,
|
|
|
|
const entries = this.gridEntries.slice(i * this.columns,
|
|
|
|
Math.min(this.gridEntries.length, (i + 1) * this.columns));
|
|
|
|
Math.min(this.gridEntries.length, (i + 1) * this.columns));
|
|
|
|
this.partitionedGridEntries.push(entries);
|
|
|
|
this.partitionedGridEntries.push(entries);
|
|
|
|
|
|
|
|
|
|
|
|
const preselectedEntry = entries.find(
|
|
|
|
const preselectedEntry = entries.find(
|
|
|
|
e => e.data.hash == this.preselectedFile?.hash);
|
|
|
|
e => e.data.id == this.preselectedFile?.id);
|
|
|
|
|
|
|
|
|
|
|
|
if (preselectedEntry) {
|
|
|
|
if (preselectedEntry) {
|
|
|
|
scrollToIndex = i;
|
|
|
|
scrollToIndex = i;
|
|
|
@ -120,6 +121,7 @@ export class FileGridComponent implements OnChanges, OnInit {
|
|
|
|
setTimeout(() => { // add timeout to avoid being stuck in the update loop
|
|
|
|
setTimeout(() => { // add timeout to avoid being stuck in the update loop
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
this.virtualScroll?.scrollToIndex(scrollToIndex);
|
|
|
|
this.virtualScroll?.scrollToIndex(scrollToIndex);
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedEntry) {
|
|
|
|
if (selectedEntry) {
|
|
|
|
selectedEntry.selected = true;
|
|
|
|
selectedEntry.selected = true;
|
|
|
|
this.selectedEntries.push(selectedEntry);
|
|
|
|
this.selectedEntries.push(selectedEntry);
|
|
|
@ -206,7 +208,33 @@ export class FileGridComponent implements OnChanges, OnInit {
|
|
|
|
this.setSelectedFile(this.gridEntries[selectedIndex]);
|
|
|
|
this.setSelectedFile(this.gridEntries[selectedIndex]);
|
|
|
|
|
|
|
|
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
this.virtualScroll.scrollToIndex(Math.floor(selectedIndex / this.columns) - 1);
|
|
|
|
const viewportSize = this.virtualScroll.getViewportSize();
|
|
|
|
|
|
|
|
let offsetTop = this.virtualScroll.measureScrollOffset("top");
|
|
|
|
|
|
|
|
const contentOffset = Math.floor(selectedIndex / this.columns) * 260;
|
|
|
|
|
|
|
|
console.log(offsetTop, contentOffset, viewportSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (contentOffset > offsetTop + viewportSize - 300 || contentOffset < offsetTop) {
|
|
|
|
|
|
|
|
this.virtualScroll.scrollToIndex(Math.floor(selectedIndex / this.columns));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offsetTop = this.virtualScroll.measureScrollOffset("top");
|
|
|
|
|
|
|
|
if (contentOffset < offsetTop + (viewportSize / 2)) {
|
|
|
|
|
|
|
|
this.virtualScroll.scrollToOffset((offsetTop + 130) - viewportSize/ 2)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private pageDown() {
|
|
|
|
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
|
|
|
|
const offsetTop = this.virtualScroll.measureScrollOffset("top");
|
|
|
|
|
|
|
|
this.virtualScroll.scrollToOffset(offsetTop + this.virtualScroll.getViewportSize());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private pageUp() {
|
|
|
|
|
|
|
|
if (this.virtualScroll) {
|
|
|
|
|
|
|
|
const offsetTop = this.virtualScroll.measureScrollOffset("top");
|
|
|
|
|
|
|
|
this.virtualScroll.scrollToOffset(offsetTop - this.virtualScroll.getViewportSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -228,6 +256,12 @@ export class FileGridComponent implements OnChanges, OnInit {
|
|
|
|
case "ArrowUp":
|
|
|
|
case "ArrowUp":
|
|
|
|
this.handleArrowSelect("up");
|
|
|
|
this.handleArrowSelect("up");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "PageDown":
|
|
|
|
|
|
|
|
this.pageDown();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "PageUp":
|
|
|
|
|
|
|
|
this.pageUp();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "a":
|
|
|
|
case "a":
|
|
|
|
case "A":
|
|
|
|
case "A":
|
|
|
|
if (this.shiftClicked && this.ctrlClicked) {
|
|
|
|
if (this.shiftClicked && this.ctrlClicked) {
|
|
|
|