Image slide out effect

Inspired by https://tympanus.net/Development/SlideOutBoxMenu/

by Julien Roche

HTML

<body class="layout">
  <section class="layout__content">
    <div class="slide-container slide-container--image1"></div>
    <div class="slide-container slide-container--image2"></div>
  </section>
  <footer class="layout__footer">
    <button type="button">Side in motion</button>
  </footer>
</body>

CSS

html,
body {
  border: none;
  height: 100%;
  margin: 0 0 0 0;
  padding: 0 0 0 0;
  width: 100%;
}


.layout {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layout__content {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
}

.layout__footer {
  background-color: black;
  flex: 0 0 auto;
  height: 3rem;
  line-height: 3rem;
  text-align: center;
}


.slide-container {
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: cover;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

.slide-container--image1 {
  background-image: url(https://images.pexels.com/photos/289225/pexels-photo-289225.jpeg?auto=compress&cs=tinysrgb&h=650&w=940);
}

.slide-container--image2 {
  background-image: url(https://images.pexels.com/photos/762020/pexels-photo-762020.jpeg?auto=compress&cs=tinysrgb&h=650&w=940);
  left: 100%;
}

.slide-container--image1.slide-container--move-slide-with-zoom {
  animation: moveSlide 1s ease-in 0s 1 normal forwards running, zoomInOut 1s ease-in 0s 1 normal forwards running;
}

.slide-container--image2.slide-container--move-slide-with-zoom {
  animation: moveSlide2 1s ease-in 0s 1 normal forwards running, zoomInOut 1s ease-in 0s 1 normal forwards running;
}

@keyframes moveSlide {
  0% {
    left: 0;
  }
  
  100% {
    left: -100%;
  }
}

@keyframes moveSlide2 {
  0% {
    left: 100%;
  }
  
  100% {
    left: 0;
  }
}

@keyframes zoomInOut {
  0% {
    transform: scale(1, 1);
  }
  
  50% {
    transform: scale(1.2, 1.2);
  }
  
  100% {
    transform: scale(1, 1);
  }
}

Babel + JSX

const buttonElement = document.querySelector('button');
const firstImageElement = document.querySelector('.slide-container--image1');
const secondImageElement = document.querySelector('.slide-container--image2');

buttonElement.addEventListener('click', (event) => {
	firstImageElement.classList.toggle('slide-container--move-slide-with-zoom');
  secondImageElement.classList.toggle('slide-container--move-slide-with-zoom');

}, false);