#260 (fix attempt 2): static-width copy feedback via .swapbtn
This commit is contained in:
@@ -18,17 +18,12 @@ function toggleStats() {
|
||||
}
|
||||
function copyFeedback(btn) {
|
||||
if (!btn) return;
|
||||
if (!btn.dataset.label) btn.dataset.label = btn.textContent; // remember the original label (Copy/Link)
|
||||
// #260: keep the button width static during the feedback so surrounding
|
||||
// elements never jump. Pin the pre-swap width, release it on restore.
|
||||
if (!btn.dataset.pinned) {
|
||||
btn.style.minWidth = Math.ceil(btn.getBoundingClientRect().width) + 'px';
|
||||
btn.dataset.pinned = '1';
|
||||
}
|
||||
// #260 attempt 2: .swapbtn stacks the label and checkmark in the same grid
|
||||
// cell, so the button width is always the wider of the two and never moves.
|
||||
// Feedback is a pure class toggle; no width pinning, no textContent swap.
|
||||
btn.classList.add('ok');
|
||||
btn.textContent = '✓';
|
||||
clearTimeout(btn._okh);
|
||||
btn._okh = setTimeout(() => { btn.classList.remove('ok'); btn.textContent = btn.dataset.label; }, 2000);
|
||||
btn._okh = setTimeout(() => btn.classList.remove('ok'), 2000);
|
||||
}
|
||||
function copyContent(btn) {
|
||||
navigator.clipboard.writeText(document.getElementById('raw-content').value)
|
||||
|
||||
Reference in New Issue
Block a user