(function ($) {
  $(window).on("elementor/frontend/init", function () {
    elementorFrontend.hooks.addAction(
      "frontend/element_ready/ignition-image-comparison.default",
      function ($scope) {
        var $comparisons = $($scope).find(".ignition-image-comparison");

        $comparisons.each(function () {
          var container = $(this);
          var offset = container.data("offset");
          var orientation = container.data("orientation");
          var before = container.data("before-label");
          var after = container.data("after-label");
          var overlay = container.data("overlay");
          var hover = container.data("hover");
          var handle = container.data("handle");
          var click = container.data("click");

          container.imagesLoaded(function () {
            container.twentytwenty({
              default_offset_pct: offset,
              orientation: orientation,
              before_label: before,
              after_label: after,
              no_overlay: overlay,
              move_slider_on_hover: hover,
              move_with_handle_only: handle,
              click_to_move: click,
            });
          });
        });
      }
    );
  });
})(jQuery);
