/******/ (() => { // webpackBootstrap
/*!*************************************************************!*\
  !*** ./src/parallax-slider/parallax-slider-wrapper/view.js ***!
  \*************************************************************/
/**
 * Use this file for JavaScript code that you want to run in the front-end
 * on posts/pages that contain this block.
 *
 * When this file is defined as the value of the `viewScript` property
 * in `block.json` it will be enqueued on the front end of the site.
 *
 * Example:
 *
 * ```js
 * {
 *   "viewScript": "file:./view.js"
 * }
 * ```
 *
 * If you're not making any changes to this file because your project doesn't need any
 * JavaScript running in the front-end, then you should delete this file and remove
 * the `viewScript` property from `block.json`.
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script
 */

const ParallaxSliderModule = {
  config: {
    containerSelector: '.parallax-slider-container',
    sectionSelector: '.parallax-section',
    bgSelector: '.bg'
  },
  instances: [],
  // Pour stocker toutes les instances

  init: function (customConfig = {}) {
    this.config = {
      ...this.config,
      ...customConfig
    };

    // On récupère tous les containers
    const containers = document.querySelectorAll(this.config.containerSelector);

    // On crée une instance pour chaque container
    containers.forEach((container, containerIndex) => {
      const sections = container.querySelectorAll(this.config.sectionSelector);
      if (sections.length) {
        this.setupContainer(container, sections, containerIndex);
      }
    });
    return this;
  },
  setupContainer: function (container, sections, containerIndex) {
    // Définit la variable CSS pour le margin-bottom de ce container
    container.style.setProperty('--section-count', sections.length);

    // Setup des sections de ce container
    sections.forEach((section, sectionIndex) => {
      section.style.top = `${sectionIndex * 100}vh`;
    });

    // Stocke les infos de cette instance
    this.instances.push({
      container,
      sections,
      containerIndex
    });
  },
  destroy: function () {
    this.instances = [];
  }
};

// Initialisation
document.addEventListener('DOMContentLoaded', () => {
  ParallaxSliderModule.init();
});
/******/ })()
;
//# sourceMappingURL=view.js.map