templates/app/_inc/_beforeafter.html.twig line 1

Open in your IDE?
  1. <script>
  2.     let before_afters = document.querySelectorAll('.before-after');
  3.     before_afters.forEach(function (before_after) {
  4.         let divisor = before_after.querySelector(".img-before"),
  5.             handle = before_after.querySelector("#handle"),
  6.             slider = before_after.querySelector("#track");
  7.         slider.oninput = function () {
  8.             moveDivisor();
  9.         }
  10.         function moveDivisor() {
  11.             handle.style.left = slider.value + "%";
  12.             divisor.style.width = slider.value + "%";
  13.         }
  14.         window.onload = function () {
  15.             moveDivisor();
  16.         };
  17.     });
  18. </script>