PageSourceSearch

https://www.veolia.cn/themes/custom/veo_site/build/assets/scripts/utils/breakpoints.js?v=10.6.15

js veolia.cn collected 2026-10-02 06:02:01 UTC 1,759 bytes, 74 lines download raw bytes

1(function (window) {
2  'use strict';
3
4  const BREAKPOINTS = {
5    mobile: 0,
6    tablet: 768,
7    desktop: 1024,
8  };
9
10  let current = getCurrentBreakpoint();
11  const listeners = [];
12
13  function getCurrentBreakpoint() {
14    const width = window.innerWidth;
15    if (width < BREAKPOINTS.tablet) return 'mobile';
16    if (width < BREAKPOINTS.desktop) return 'tablet';
17    return 'desktop';
18  }
19
20  function triggerChange(newBp, oldBp) {
21    listeners.forEach((cb) => cb({ breakpoint: newBp, prevBreakpoint: oldBp }));
22  }
23
24  function onChangeBreakpoint(callback) {
25    if (typeof callback === 'function') {
26      listeners.push(callback);
27    }
28  }
29
30  // Debounced resize handler
31  const debounce = (fn, delay = 100) => {
32    let timer;
33    return function () {
34      clearTimeout(timer);
35      timer = setTimeout(() => fn.apply(this, arguments), delay);
36    };
37  };
38
39  function checkBreakpoint() {
40    const newBreakpoint = getCurrentBreakpoint();
41    if (newBreakpoint !== current) {
42      const prev = current;
43      current = newBreakpoint;
44      triggerChange(newBreakpoint, prev);
45    }
46  }
47
48  // Initial and runtime listeners
49  const startWatching = () => {
50    window.addEventListener('resize', debounce(checkBreakpoint));
51    window.addEventListener('orientationchange', checkBreakpoint);
52
53    // Optional: periodically double-check in case of dynamic layout shifts
54    setInterval(() => {
55      checkBreakpoint();
56    }, 1000);
57  };
58
59  // Run once DOM is ready
60  if (document.readyState === 'loading') {
61    document.addEventListener('DOMContentLoaded', checkBreakpoint);
62  } else {
63    checkBreakpoint();
64  }
65
66  startWatching();
67
68  // Public API
69  window.Breakpoints = {
70    get: getCurrentBreakpoint,
71    onChange: onChangeBreakpoint
72  };
73
74})(window);

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.