<?php
/*
Theme Name: Salient Child Theme
Description: This is a custom child theme for Salient
Theme URI:   https://themeforest.net/item/salient-responsive-multipurpose-theme/4363266
Author: ThemeNectar
Author URI:  https://themeforest.net/user/themenectar
Template: salient
Version: 1.0
*/

add_action('wp_enqueue_scripts', function () {

  wp_enqueue_script(
    'panzoom',
    'https://unpkg.com/@panzoom/panzoom/dist/panzoom.min.js',
    ['jquery'],
    null,
    true
  );

 wp_add_inline_script(
  'panzoom',
  "
  jQuery(document).on('pumAfterOpen', function () {

    document.querySelectorAll('.panzoom-img').forEach(function (img) {
      if (img._panzoom) return;

      const initPanzoom = function () {
        const panzoom = Panzoom(img, {
          maxScale: 5,
          minScale: 1,
          contain: 'outside'
        });

        img.parentElement.addEventListener('wheel', panzoom.zoomWithWheel);
        img._panzoom = panzoom;
      };

      if (img.complete) {
        initPanzoom();
      } else {
        img.addEventListener('load', initPanzoom, { once: true });
      }
    });

  });
  ",
  'after'
);


});
