Add small animation when opening files

This commit is contained in:
Nils Maier 2019-09-05 08:31:41 +02:00
parent 2d1f185fcd
commit 639a582804
3 changed files with 27 additions and 2 deletions

View File

@ -18,6 +18,7 @@
--folder-color: rgb(214, 165, 4); --folder-color: rgb(214, 165, 4);
--maskbutton-color: rgb(236, 185, 16); --maskbutton-color: rgb(236, 185, 16);
--missing-color: rgb(0, 82, 204); --missing-color: rgb(0, 82, 204);
--open-color: rgba(236, 185, 16, 0.8);
} }
html[data-platform="mac"] { html[data-platform="mac"] {

View File

@ -154,6 +154,10 @@ body > * {
height: 26px; height: 26px;
} }
.virtualtable-row.opening {
background: var(--open-color) !important;
}
.virtualtable-progress-container { .virtualtable-progress-container {
border-radius: 2px; border-radius: 2px;
} }

View File

@ -144,6 +144,8 @@ export class DownloadItem extends EventEmitter {
private largeIconField?: string; private largeIconField?: string;
public opening: boolean;
constructor(owner: DownloadTable, raw: any, stats?: Stats) { constructor(owner: DownloadTable, raw: any, stats?: Stats) {
super(); super();
Object.assign(this, raw); Object.assign(this, raw);
@ -802,20 +804,29 @@ export class DownloadTable extends VirtualTable {
} }
async openFile() { async openFile() {
if (this.focusRow < 0) { const {focusRow} = this;
if (focusRow < 0) {
return; return;
} }
const item = this.downloads.filtered[this.focusRow]; const item = this.downloads.filtered[focusRow];
if (!item || !item.manId || item.state !== DownloadState.DONE) { if (!item || !item.manId || item.state !== DownloadState.DONE) {
return; return;
} }
item.opening = true;
try { try {
this.invalidateRow(focusRow);
await downloads.open(item.manId); await downloads.open(item.manId);
} }
catch (ex) { catch (ex) {
console.error(ex, ex.toString(), ex); console.error(ex, ex.toString(), ex);
PORT.post("missing", {sid: item.sessionId}); PORT.post("missing", {sid: item.sessionId});
} }
finally {
setTimeout(() => {
item.opening = false;
this.invalidateRow(focusRow);
}, 500);
}
} }
async openDirectory() { async openDirectory() {
@ -1112,7 +1123,16 @@ export class DownloadTable extends VirtualTable {
if (!item) { if (!item) {
return null; return null;
} }
if (item.opening) {
return ["opening"];
}
const cls = StateClasses.get(item.state); const cls = StateClasses.get(item.state);
if (cls && item.opening) {
return [cls, "opening"];
}
if (item.opening) {
return ["opening"];
}
return cls && [cls] || null; return cls && [cls] || null;
} }