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

        $galleries.each(function (index, gallery) {
          var $gallery = $(gallery);
          var rowHeight = $gallery.data("row-height");
          var margins = $gallery.data("margins");
          var lastRow = $gallery.data("last-row");
          var randomize = $gallery.data("randomize");
          var selector = $gallery.data("selector");
          $gallery.removeClass("hide-gallery");
          $gallery.justifiedGallery({
            rowHeight: rowHeight,
            margins: margins,
            lastRow: lastRow,
            randomize: randomize,
            selector: selector,
          });
        });
      }
    );
  });
})(jQuery);
