As you can see in the code below. If you change the style and then change it again right away, there is no transition. However, if you just wait a little bit, it will work. I'm wondering if there's anything that can be monitored to know when you can change the style again such that it won't bypass the transition.
let one = document.getElementById('one');
let two = document.getElementById('two');
one.style.left = '100px';
one.style.left = 0;
two.style.left = '100px'
setTimeout(()=> two.style.left = 0, 100);
div {
position: absolute;
width: 100px;
height: 100px;
border: solid;
transition: left 1s;
}
#two {
top: 150px;
}
<div id='one'></div>
<div id='two'></div>
Edit: This appears to be a simple case of using an no-delay setTimeout
, and indeed that does work for my example code. However, in my actual code that does not work. I'm not sure what's going on. I am unable to make a simple example of it that doesn't work but I'm guessing it has something to do with having more content on the page.