'How do I make my box go from centre to smoothly transition across to the top left after a 1 second set interval?
Trying to do a smooth transition logo from the centre of my browser to the top, left corner after my set interval timer has done 1 second.
What is the best approach for this?
Current code below.
var timesRun = 0;
window.onload = loader()
function loader(){
var newinterval = setInterval(function(){
timesRun += 1;
if(timesRun === 1){
clearInterval(newinterval);
moveLogo();
}
}, 1000);
}
function moveLogo(){
// ????????????
const logo = document.querySelector('.box')
logo.className = 'left'
logo.style.transition = 'all 0.5s';
logo.style.transform = 'translate(0%, 0%)';
}
.box {
position: absolute;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
display: flex;
align-items: center;
justify-content: space-around;
width: 220px;
height:80px;
color: green;
border: 1px solid black;
};
<div class="box"></div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
