From 4dc4861f4ca1f3edac78872d8501ef9e0d8158cb Mon Sep 17 00:00:00 2001 From: Ashish Pandey Date: Wed, 14 May 2025 13:31:03 +0545 Subject: [PATCH] prevent scroll-to-top on restart/fast buttons in termynal.js --- docs/en/docs/js/termynal.js | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/en/docs/js/termynal.js b/docs/en/docs/js/termynal.js index 4ac32708a..9872fad2e 100644 --- a/docs/en/docs/js/termynal.js +++ b/docs/en/docs/js/termynal.js @@ -127,32 +127,32 @@ class Termynal { } generateRestart() { - const restart = document.createElement('a') - restart.onclick = (e) => { - e.preventDefault() - this.container.innerHTML = '' - this.init() - } - restart.href = '#' - restart.setAttribute('data-terminal-control', '') - restart.innerHTML = "restart ↻" - return restart - } + const restart = document.createElement('a'); + restart.href = 'javascript:void(0)'; + restart.setAttribute('data-terminal-control', ''); + restart.innerHTML = "restart ↻"; + restart.onclick = (e) => { + e.preventDefault(); + this.container.innerHTML = ''; + this.init(); + }; + return restart; +} generateFinish() { - const finish = document.createElement('a') - finish.onclick = (e) => { - e.preventDefault() - this.lineDelay = 0 - this.typeDelay = 0 - this.startDelay = 0 - } - finish.href = '#' - finish.setAttribute('data-terminal-control', '') - finish.innerHTML = "fast →" - this.finishElement = finish - return finish - } + const finish = document.createElement('a'); + finish.href = 'javascript:void(0)'; + finish.setAttribute('data-terminal-control', ''); + finish.innerHTML = "fast →"; + finish.onclick = (e) => { + e.preventDefault(); + this.lineDelay = 0; + this.typeDelay = 0; + this.startDelay = 0; + }; + this.finishElement = finish; + return finish; +} addRestart() { const restart = this.generateRestart()