function getRandomPosition() {
let windowWidth = window.innerWidth – 200; // 200px offset to keep text within bounds
let windowHeight = window.innerHeight – 50; // 50px offset to keep text within bounds
let randomX = Math.floor(Math.random() * windowWidth);
let randomY = Math.floor(Math.random() * windowHeight);
return { x: randomX, y: randomY };
}
function moveText() {
let text = document.getElementById(“moving-text”);
let position = getRandomPosition();
text.style.left = position.x + “px”;
text.style.top = position.y + “px”;
}
setInterval(moveText, 2000); // 2 saniyede bir yer değiştir
document.addEventListener(“DOMContentLoaded”, function() {
moveText(); // Sayfa yüklendiğinde ilk konumlandırma
});