52
redigeringer
Diversen (diskussion | bidrag) No edit summary Tag: Tilbagerullet |
Diversen (diskussion | bidrag) No edit summary Tag: Manuel tilbagerulning |
||
Linje 61: | Linje 61: | ||
// Debounce function in ES5 syntax | |||
function debounce(func, wait) { | |||
var timeout; | |||
return function() { | |||
var context = this, args = arguments; | |||
clearTimeout(timeout); | |||
timeout = setTimeout(function() { | |||
func.apply(context, args); | |||
}, wait); | |||
}; | |||
} | |||
// Function to reload the page | // Function to reload the page | ||
function reloadPage() { | function reloadPage() { | ||
Linje 66: | Linje 78: | ||
} | } | ||
// Set up the | // Set up the resize event listener with debounce | ||
window.addEventListener(' | window.addEventListener('resize', debounce(reloadPage, 250)); // 250 milliseconds |