Here it is working: where both are identical: https://jsfiddle.net/sunepr5b/
What if each held different images?
Seen here: https://jsfiddle.net/r40u76h8/
<div class="slide panel-left">
<div class="inner">
<div class="container2">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 1">
<div>
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 2">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 3">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 4">
</div>
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 5">
</div>
</div>
</div>
<div class="slide panel-right">
<div class="inner">
<div class="slide container2">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 1">
<div>
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 2">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 3">
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 4">
</div>
<img src="https://i.imgur.com/2NcDQ1H.png" alt="Image 5">
</div>
</div>
</div>
<div class="slide curtain-left hide">
<div class="inner">
<div class="container2">
<img src="https://i.imgur.com/z5MMJnv.png" alt="Image 1">
<div>
<img src="https://i.imgur.com/5u16syR.png" alt="Image 2">
<img src="https://i.imgur.com/ygTtvme.png" alt="Image 3">
<img src="https://i.imgur.com/QziKNDW.png" alt="Image 4">
</div>
<img src="https://i.imgur.com/8Jf8LLc.png" alt="Image 5">
</div>
</div>
</div>
<div class="slide curtain-right hide">
<div class="inner">
<div class="slide container2">
<img src="https://i.imgur.com/z5MMJnv.png" alt="Image 1">
<div>
<img src="https://i.imgur.com/5u16syR.png" alt="Image 2">
<img src="https://i.imgur.com/ygTtvme.png" alt="Image 3">
<img src="https://i.imgur.com/QziKNDW.png" alt="Image 4">
</div>
<img src="https://i.imgur.com/8Jf8LLc.png" alt="Image 5">
</div>
</div>
</div>
This part here would need to be adjusted:
const curtainLeft = document.querySelector('.curtain-left');
const curtainRight = document.querySelector('.curtain-right');
curtainLeft.style.transition = 'none';
curtainRight.style.transition = 'none';
const modal = document.getElementById('myModal');
modal.style.display = 'none';
modal.classList.add("open");
modal.offsetWidth = modal.offsetWidth;
curtainLeft.style.transition = null;
curtainRight.style.transition = null;
modal.classList.remove("open");
}