BlueGit

timfa filemanager

Fix: clone SVG before hiding so ghost is visible; fix data undefined in incrementalRefreshCurrentDir

timfa Tim Falken · pushed by timfa

Authored 2026-05-03 · 6 months ago

Hash
bc9a0372cbcb4bf7c4d02f795c39c65cc50a8767
Parent
47bffce2
1 file changed +9 −7
public/app.js +9 −7
@@ -811,7 +811,8 @@ function itemsSignature (items)
811 811 async function incrementalRefreshCurrentDir ()
812 812 {
813 813 if (!STATE.currentDir || STATE.uploadInProgress) return;
814 closeSidebar();
814
815 const data = await api('GET', `/files/list?dir=${encodeURIComponent(STATE.currentDir)}`).catch(() => null);
815 816 if (!data) return;
816 817
817 818 const oldSig = itemsSignature(STATE.items);
@@ -1240,9 +1241,6 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1240 1241 const end = sheetEl.getBoundingClientRect();
1241 1242 if (!start.width || !start.height || !end.width || !end.height) return Promise.resolve({ startScale: 0.12 });
1242 1243
1243 // Hide source icon for the duration of the preview
1244 sourceSvgEl.style.visibility = 'hidden';
1245
1246 1244 const ghost = document.createElement('div');
1247 1245 ghost.className = 'preview-ghost';
1248 1246 ghost.style.left = `${start.left}px`;
@@ -1250,7 +1248,10 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1250 1248 ghost.style.width = `${start.width}px`;
1251 1249 ghost.style.height = `${start.height}px`;
1252 1250
1251 // Clone before hiding so the ghost is a visible copy
1253 1252 const clone = sourceSvgEl.cloneNode(true);
1253 // Hide source icon for the duration of the preview
1254 sourceSvgEl.style.visibility = 'hidden';
1254 1255 clone.style.width = '100%';
1255 1256 clone.style.height = '100%';
1256 1257 clone.style.display = 'block';
@@ -1276,7 +1277,8 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1276 1277 const startScale = start.width / end.width;
1277 1278
1278 1279 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1279 function bezier1D (p0, p1, p2, p3, t) {
1280 function bezier1D (p0, p1, p2, p3, t)
1281 {
1280 1282 const u = 1 - t;
1281 1283 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1282 1284 }
@@ -1314,7 +1316,6 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1314 1316 requestAnimationFrame(frame);
1315 1317 });
1316 1318 }
1317 }
1318 1319
1319 1320 function animatePreviewClose (sourceSvgEl, sheetEl)
1320 1321 {
@@ -1352,7 +1353,8 @@ function animatePreviewClose (sourceSvgEl, sheetEl)
1352 1353 const startTime = performance.now();
1353 1354
1354 1355 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1355 function bezier1D (p0, p1, p2, p3, t) {
1356 function bezier1D (p0, p1, p2, p3, t)
1357 {
1356 1358 const u = 1 - t;
1357 1359 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1358 1360 }
@@ -811,7 +811,8 @@ function itemsSignature (items)
811async function incrementalRefreshCurrentDir ()
811async function incrementalRefreshCurrentDir ()
812{
812{
813 if (!STATE.currentDir || STATE.uploadInProgress) return;
813 if (!STATE.currentDir || STATE.uploadInProgress) return;
814 closeSidebar();
814
815 const data = await api('GET', `/files/list?dir=${encodeURIComponent(STATE.currentDir)}`).catch(() => null);
815 if (!data) return;
816 if (!data) return;
816
817
817 const oldSig = itemsSignature(STATE.items);
818 const oldSig = itemsSignature(STATE.items);
@@ -1240,9 +1241,6 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1240 const end = sheetEl.getBoundingClientRect();
1241 const end = sheetEl.getBoundingClientRect();
1241 if (!start.width || !start.height || !end.width || !end.height) return Promise.resolve({ startScale: 0.12 });
1242 if (!start.width || !start.height || !end.width || !end.height) return Promise.resolve({ startScale: 0.12 });
1242
1243
1243 // Hide source icon for the duration of the preview
1244 sourceSvgEl.style.visibility = 'hidden';
1245
1246 const ghost = document.createElement('div');
1244 const ghost = document.createElement('div');
1247 ghost.className = 'preview-ghost';
1245 ghost.className = 'preview-ghost';
1248 ghost.style.left = `${start.left}px`;
1246 ghost.style.left = `${start.left}px`;
@@ -1250,7 +1248,10 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1250 ghost.style.width = `${start.width}px`;
1248 ghost.style.width = `${start.width}px`;
1251 ghost.style.height = `${start.height}px`;
1249 ghost.style.height = `${start.height}px`;
1252
1250
1251 // Clone before hiding so the ghost is a visible copy
1253 const clone = sourceSvgEl.cloneNode(true);
1252 const clone = sourceSvgEl.cloneNode(true);
1253 // Hide source icon for the duration of the preview
1254 sourceSvgEl.style.visibility = 'hidden';
1254 clone.style.width = '100%';
1255 clone.style.width = '100%';
1255 clone.style.height = '100%';
1256 clone.style.height = '100%';
1256 clone.style.display = 'block';
1257 clone.style.display = 'block';
@@ -1276,7 +1277,8 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1276 const startScale = start.width / end.width;
1277 const startScale = start.width / end.width;
1277
1278
1278 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1279 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1279 function bezier1D (p0, p1, p2, p3, t) {
1280 function bezier1D (p0, p1, p2, p3, t)
1281 {
1280 const u = 1 - t;
1282 const u = 1 - t;
1281 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1283 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1282 }
1284 }
@@ -1314,7 +1316,6 @@ function animatePreviewOpen (sourceSvgEl, sheetEl)
1314 requestAnimationFrame(frame);
1316 requestAnimationFrame(frame);
1315 });
1317 });
1316}
1318}
1317}
1318
1319
1319function animatePreviewClose (sourceSvgEl, sheetEl)
1320function animatePreviewClose (sourceSvgEl, sheetEl)
1320{
1321{
@@ -1352,7 +1353,8 @@ function animatePreviewClose (sourceSvgEl, sheetEl)
1352 const startTime = performance.now();
1353 const startTime = performance.now();
1353
1354
1354 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1355 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1355 function bezier1D (p0, p1, p2, p3, t) {
1356 function bezier1D (p0, p1, p2, p3, t)
1357 {
1356 const u = 1 - t;
1358 const u = 1 - t;
1357 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1359 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1358 }
1360 }