PageSourceSearch

https://www.ircagroup.com/themes/irca/build/js/shared/zoom-page-scroll.js?tm68pa

js ircagroup.com collected 2026-10-10 01:02:30 UTC 5,425 bytes, 139 lines download raw bytes

1/******/ (() => { // webpackBootstrap
2/*!**********************************************!*\
3  !*** ./assets/js/shared/zoom-page-scroll.js ***!
4  \**********************************************/
5(function (Drupal) {
6  'use strict';
7
8  Drupal.behaviors.zoomPageScroll = {
9    attach: function attach(context, settings) {
10      if (context != '[object HTMLDocument]') return;
11
12      // Su MOBILE disattiviamo lo zoom: la transform:scale() continua su
13      // .layout-content ad ogni scroll costringe iOS a ricompositare l'intera
14      // pagina scalata -> saturazione GPU/memoria -> crash "problema ripetuto".
15      // Su desktop resta attivo.
16      // if (!window.matchMedia('(min-width: 768px)').matches) return;
17
18      var debug = false;
19      debug && console.log('zoom-page-scroll inizializzato!');
20      var heroBlock = null;
21      var type = null;
22      if (document.querySelector('#block-irca-views-block-slide-homepage-hp-slider .views-view--slide-homepage')) {
23        heroBlock = document.querySelector('#block-irca-views-block-slide-homepage-hp-slider .views-view--slide-homepage');
24        type = 'hp-slider';
25      } else if (document.querySelector('#block-irca-content .hero-full .content')) {
26        heroBlock = document.querySelector('#block-irca-content .hero-full .content');
27        type = 'generic-slider';
28      } else {
29        return;
30      }
31      var layoutContent = document.querySelector('.layout-content');
32      if (!heroBlock) {
33        console.log('ERRORE: Elementi non trovati per zoom-page-scroll');
34        return;
35      }
36      debug && console.log('layoutContent:', layoutContent);
37      debug && console.log('heroBlock:', heroBlock);
38      if (!layoutContent || !heroBlock) {
39        console.log('ERRORE: Elementi non trovati per zoom-page-scroll');
40        console.log('layoutContent trovato:', !!layoutContent);
41        console.log('heroBlock trovato:', !!heroBlock);
42        return;
43      }
44
45      // Scale iniziale e finale
46      var minScale = 0.8;
47      var maxScale = 1.0;
48      debug && console.log('Elementi trovati, configurazione zoom-page-scroll completata');
49
50      // Imposta lo stato iniziale
51      layoutContent.style.transform = "scale(".concat(minScale, ")");
52      layoutContent.style.transformOrigin = "center ".concat(type === 'hp-slider' ? window.innerHeight : heroBlock.offsetHeight, "px");
53      // Scroll to top della pagina
54      window.scrollTo({
55        top: 0,
56        behavior: 'smooth'
57      });
58      var lastScale = minScale;
59      var ticking = false;
60      function handleScroll() {
61        debug && console.log('SCROLL EVENT TRIGGERED!');
62
63        // Ottieni la posizione del bordo superiore dell'elemento hero rispetto alla viewport
64        var heroRect = heroBlock.getBoundingClientRect();
65        var heroTop = heroRect.top - 200;
66
67        // Calcola il progresso dello scroll (0 = inizio, 1 = hero tocca il top)
68        var windowHeight = window.innerHeight;
69        var maxDistance = windowHeight;
70        var progress = Math.max(0, Math.min(1, (maxDistance - heroTop) / maxDistance));
71
72        // Calcola la scala target
73        var targetScale = minScale + (maxScale - minScale) * progress;
74
75        // Solo se la differenza è significativa, aggiorna
76        var scaleDifference = Math.abs(targetScale - lastScale);
77        if (scaleDifference > 0.001) {
78          // Usa una transizione CSS fluida invece di Anime.js per performance migliori
79          layoutContent.style.transition = 'transform 0.1s ease-out';
80          layoutContent.style.transform = "scale(".concat(target
80Scale, ")");
81          lastScale = targetScale;
82          if (targetScale == 1) {
83            layoutContent.style.transform = "initial";
84          }
85          debug && console.log("Hero top: ".concat(heroTop.toFixed(2), ", Progress: ").concat(progress.toFixed(2), ", Scale: ").concat(targetScale.toFixed(3)));
86        }
87      }
88
89      // Throttle function ottimizzata
90      function requestTick() {
91        if (!ticking) {
92          ticking = true;
93          requestAnimationFrame(function () {
94            handleScroll();
95            ticking = false;
96          });
97        }
98      }
99
100      // Test immediato della funzione
101      debug && console.log('Test immediato della funzione handleScroll:');
102      handleScroll();
103
104      // Aggiungi l'event listener per lo scroll con throttling ottimizzato
105      debug && console.log('Aggiungendo event listener per scroll...');
106      window.addEventListener('scroll', requestTick, {
107        passive: true
108      });
109      debug && console.log('Event listener aggiunto!');
110
111      // Test per verificare se l'event listener funziona
112      setTimeout(function () {
113        debug && console.log('Test scroll programmatico...');
114        window.scrollBy(0, 1);
115      }, 1000);
116
117      // Aggiungi anche un listener per il resize
118      window.addEventListener('resize', function () {
119        requestTick();
120      }, {
121        passive: true
122      });
123
124      // Cleanup function per rimuovere event listeners quando necessario
125      var cleanup = function cleanup() {
126        window.removeEventListener('scroll', requestTick);
127        window.removeEventListener('resize', requestTick);
128      };
129
130      // Salva la funzione di cleanup per uso futuro se necessario
131      if (window.zoomPageScrollCleanup) {
132        window.zoomPageScrollCleanup();
133      }
134      window.zoomPageScrollCleanup = cleanup;
135    }
136  };
137})(Drupal);
138/******/ })()
139;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.