Skip to content

Commit 95118cb

Browse files
craig[bot]wenyihu6
andcommitted
Merge #153546
153546: asimview: fix scrolling with sha_compare.html r=tbg a=wenyihu6 Epic: none Release note: none ---- Previously, scrolling didn't work with sha_compare.html in non-full-page mode when zoomed in. This commit fixes it. 🤖 Generated with Claude Code Co-Authored-By: Claude [[email protected]](mailto:[email protected]) Co-authored-by: wenyihu6 <[email protected]>
2 parents 3f6a4f4 + 22e7e98 commit 95118cb

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

pkg/kv/kvserver/asim/tests/cmd/asimview/sha_compare.html

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,20 @@
2222
.status.success { background: #d4edda; color: #155724; }
2323
.comparison-controls { background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
2424
.file-selector { display: flex; gap: 20px; align-items: center; }
25-
.file-list { flex: 1; max-height: 400px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; }
25+
.file-list {
26+
flex: 1;
27+
max-height: 400px;
28+
overflow-y: auto;
29+
overflow-x: hidden;
30+
border: 1px solid #ddd;
31+
border-radius: 4px;
32+
-webkit-overflow-scrolling: touch;
33+
scroll-behavior: smooth;
34+
outline: none;
35+
/* Custom scrollbar styling */
36+
scrollbar-width: thin;
37+
scrollbar-color: #ccc #f5f5f5;
38+
}
2639
.file-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #eee; }
2740
.file-item:hover { background: #f8f9fa; }
2841
.file-item.selected {
@@ -435,11 +448,11 @@ <h3 id="sha2-title">SHA 2</h3>
435448

436449
updateFileList() {
437450
const fileList = document.getElementById('file-list');
438-
451+
439452
fileList.innerHTML = this.fileComparisons.map(file => {
440453
let backgroundColor = '#51cf66'; // Default: identical (green)
441454
let borderColor = '#51cf66';
442-
455+
443456
if (file.hasDiff) {
444457
if (file.onlyInSha1) {
445458
backgroundColor = '#ffd43b'; // Only in SHA1 (yellow)
@@ -452,14 +465,45 @@ <h3 id="sha2-title">SHA 2</h3>
452465
borderColor = '#ff6b6b';
453466
}
454467
}
455-
468+
456469
return `
457470
<div class="file-item" onclick="viewer.selectFile('${file.path}')" data-path="${file.path}"
458471
style="border-left: 4px solid ${borderColor}; background: linear-gradient(90deg, ${backgroundColor}20 0%, white 15%);">
459472
${file.name}
460473
</div>
461474
`;
462475
}).join('');
476+
477+
// Add mouse wheel scrolling support
478+
this.setupFileListScrolling();
479+
}
480+
481+
setupFileListScrolling() {
482+
const fileList = document.getElementById('file-list');
483+
if (!fileList) return;
484+
485+
// Remove existing listeners to prevent duplicates
486+
fileList.removeEventListener('wheel', this.handleFileListScroll);
487+
488+
// Add wheel event listener for custom scrolling
489+
this.handleFileListScroll = (e) => {
490+
// Prevent default page scrolling
491+
e.preventDefault();
492+
e.stopPropagation();
493+
494+
// Calculate scroll amount with smoother, less laggy scrolling
495+
const scrollAmount = e.deltaY * 1.5;
496+
497+
// Use requestAnimationFrame for smoother scrolling
498+
requestAnimationFrame(() => {
499+
fileList.scrollTop += scrollAmount;
500+
});
501+
};
502+
503+
fileList.addEventListener('wheel', this.handleFileListScroll, { passive: false });
504+
505+
// Also ensure the element is focusable for better interaction
506+
fileList.setAttribute('tabindex', '0');
463507
}
464508

465509
async selectFile(filePath) {

0 commit comments

Comments
 (0)