Lets say I have this code:
function hide(num){
$("#text" + num).fadeOut();
}
function show(num){
$("#text" + num).fadeIn();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<button onclick="show(1)">
Show text 1
</button>
<button onclick="show(2)">
Show text 2
</button>
<button onclick="hide(1)">
Hide text 1
</button>
<button onclick="hide(2)">
Hide text 2
</button>
<p id="text1">
Text1
</p>
<p id="text2">
Text2
</p>
When you click "Hide Text1" Text1 fades away smoothly but Text2 automatically teleports to its position. Is there a way to make this "teleport" more of a slide?
I know that I can animate every possible movement in JS but that gets really annoying when you autogenerate a lot of elements. Is there a way to do this for all of these automatic teleports?