PageSourceSearch

https://www.siljander.no/node_modules/@fluejs/noscroll/dist/index.mjs

js siljander.no collected 2026-10-10 02:08:12 UTC 6,573 bytes, 192 lines download raw bytes

1import { a as attrAsSelector, N as NoScrollAttrs, b as NoScrollCssVars, t as throttle, D as DEFAULT_WINDOW_RESIZE_THROTTLE, c as asArray, d as createQueue, g as getScrollbarWidth } from './shared/noscroll.96a94b32.mjs';
2
3const appendGlobalStyles = () => {
4  if (document.querySelector(attrAsSelector(NoScrollAttrs.GLOBAL_STYLES))) {
5    return;
6  }
7  const scrollDisabledSelector = attrAsSelector(NoScrollAttrs.SCROLL_DISABLED);
8  const scrollbarWidthAdjustmentSelector = attrAsSelector(NoScrollAttrs.SCROLLBAR_WIDTH_ADJUSTMENT);
9  const scrollScrollbarWidthAdjustmentSelector = attrAsSelector(NoScrollAttrs.SCROLL_SCROLLBAR_WIDTH_ADJUSTMENT);
10  const css = `    
11    ${scrollDisabledSelector} {
12        overflow: hidden !important;
13    }
14    
15    ${scrollDisabledSelector} ${scrollbarWidthAdjustmentSelector},
16    ${scrollDisabledSelector}${scrollScrollbarWidthAdjustmentSelector} {
17        padding-right: calc(var(${NoScrollCssVars.TARGET_PADDING_RIGHT}) + var(${NoScrollCssVars.TARGET_SCROLLBAR_WIDTH})) !important;
18    }
19    `;
20  const styleEl = document.createElement("style");
21  styleEl.setAttribute(NoScrollAttrs.GLOBAL_STYLES, "");
22  styleEl.appendChild(document.createTextNode(css));
23  document.head.appendChild(styleEl);
24};
25
26const createNoScroll = (options) => {
27  const adjustScrollbarWidth = (target) => {
28    asArray(target).forEach((el) => {
29      el.removeAttribute(NoScrollAttrs.SCROLLBAR_WIDTH_ADJUSTMENT);
30      const computedStyle = window.getComputedStyle(el);
31      el.style.setProperty(NoScrollCssVars.TARGET_PADDING_RIGHT, computedStyle.paddingRight);
32      el.setAttribute(NoScrollAttrs.SCROLLBAR_WIDTH_ADJUSTMENT, "");
33    });
34  };
35  const removeScrollbarWidthAdjustment = (target) => {
36    asArray(target).forEach((el) => {
37      el.removeAttribute(NoScrollAttrs.SCROLLBAR_WIDTH_ADJUSTMENT);
38      el.style.removeProperty(NoScrollCssVars.TARGET_PADDING_RIGHT);
39    });
40  };
41  const adjustScrollScrollbarWidth = (target) => {
42    asArray(target).forEach((el) => {
43      let scrollDisabled = false;
44      el.removeAttribute(NoScrollAttrs.SCROLL_SCROLLBAR_WIDTH_ADJUSTMENT);
45      if (el.getAttribute(NoScrollAttrs.SCROLL_DISABLED) !== null) {
46        scrollDisabled = true;
47        el.removeAttribute(NoScrollAttrs.SCROLL_DISABLED);
48      }
49      el.style.setProperty(NoScrollCssVars.TARGET_SCROLLBAR_WIDTH, `${getScrollbarWidth(el)}px`);
50      if (scrollDisabled) {
51        el.setAttribute(NoScrollAttrs.SCROLL_DISABLED, "");
52      }
53      const computedStyle = window.getComputedStyle(el);
54      el.style.setProperty(NoScrollCssVars.TARGET_PADDING_RIGHT, computedStyle.paddingRight);
55      el.setAttribute(NoScrollAttrs.SCROLL_SCROLLBAR_WIDTH_ADJUSTMENT, "");
56    });
57  };
58  const removeScrollScrollbarWidthAdjustment = (target) => {
59    asArray(target).forEach((el) => {
60      el.removeAttribute(NoScrollAttrs.SCROLL_SCROLLBAR_WIDTH_ADJUSTMENT);
61      el.style.removeProperty(NoScrollCssVars.TARGET_SCROLLBAR_WIDTH);
62      el.style.removeProperty(NoScrollCssVars.TARGET_PADDING_RIGHT);
63    });
64  };
65  const updateAllScrollbarWidthAdjustment = () => {
66    adjustScrollbarWidth(
67      [...document.querySelectorAll(
68        attrAsSelector(NoScrollAttrs.SCROLLBAR_WIDTH_ADJUSTMENT)
69      )]
70    );
71    adjustScrollScrollbarWidth(
72      [...document.querySelectorAll(
73        attrAsSelector(NoScrollAttrs.SCROLL_SCROLLBAR_WIDTH_ADJUSTMENT)
74      )]
75    );
76  };
77  const handleWindowResize = throttle(
78    updateAllScrollbarWidthAdjustment,
79    options?.windowResizeThrottle ?? DEFAULT_WINDOW_RESIZE_THROTTLE
80  );
81  const {
82    init: initScrollDisable,
83    reset: resetScrollDisable
84  } = createQueue(
85    () => {
86      if (!options?.noHandleWindowResize) {
87        window.addEventListener("resize", handleWindowResize);
88      }
89      options?.onInitScrollDisable?.();
90    },
91    () => {
92      if (!options?.noHandleWindowResize) {
93        window.removeEventListener("resize", handleWindowResize);
94      }
95      options?.onResetScrollDisable?.();
96    }
97  );
98  const disableScroll = (target, {
99    scrollbarWidthAdjustment = true
100  } = {}) => {
101    appendGlobalStyles();
102    initScrollDisable();
103    options?.onScrollDisable?.(target);
104    if (scrollbarWidthAdjustment) {
105      adjustScrollScrollbarWidth(target);
106    }
107    target.setAttribute(NoScrollAttrs.SCROLL_DISABLED, "");
108  };
109  const enableScroll = (target) => {
110    if (target.getAttribute(NoScrollAttrs.SCROLL_DISABLED) === null) {
111      return;
112    }
113    resetScrollDisable();
114    options?.onScrollEnable?.(target);
115    removeScrollScrollbarWidthAdjustment(target);
116    target.removeAttribute(NoScrollAttrs.SCROLL_DISABLED);
117  };
118  const {
119    init: disablePageScroll,
120    reset: enablePageScroll,
121    initIsCalled: pageScrollIsDisabled
122  } = createQueue(
123    () => disableScroll(document.body),
124    () => enableScroll(document.body)
125  );
126  const createPageScrollToggler = () => {
127    let isDisabled = false;
128    const toggler = {
129      disablePageScroll() {
130        if (isDisabled) {
131          return;
132        }
133        disablePageScroll();
134        isDisabled = true;
135      },
136      enablePageScroll() {
137        if (!isDisabled) {
138          return;
139        }
140        enablePageScroll();
141        isDisabled = false;
142      },
143      togglePageScroll() {
144        if (isDisabled) {
145          toggler.enablePageScroll();
146        } else {
147          toggler.disablePageScroll();
148        }
149      }
150    };
151    return toggler;
152  };
153  const markScrollable = (target) => {
154    asArray(target).forEach((el) => {
155      el.setAttribute(NoScrollAttrs.SCROLLABLE, "");
156    });
157  };
158  const unmarkScrollable = (target) => {
159    asArray(target).forEach((el) => {
160      el.removeAttribute(NoScrollAttrs.SCROLLABLE);
161    });
162  };
163  return {
164    adjustScrollbarWidth,
165    removeScrollbarWidthAdjustment,
166    updateAllScrollbarWidthAdjustment,
167    disableScroll,
168    enableScroll,
169    disablePageScroll,
170    enablePageScroll,
171    pageScrollIsDisabled,
172    createPageScrollToggler,
173    markScrollable,
174    unmarkScrollable
175  };
176};
177
178const {
179  adjustScrollbarWidth,
180  removeScrollbarWidthAdjustment,
181  updateAllScrollbarWidthAdjustment,
182  disableScroll,
183  enableScroll,
184  disablePageScroll,
185  enablePageScroll,
186  pageScrollIsDisabled,
187  createPageScrollToggler,
188  markScrollable,
189  unmarkScrollable
190} = createNoScroll();
191
192export { NoScrollAttrs, NoScrollCssVars, adjustScrollbarWidth, createNoScroll, createPageScrollToggler, disablePageScroll, disableScroll, enablePageScroll, enableScroll, markScrollable, pageScrollIsDisabled, removeScrollbarWidthAdjustment, unmarkScrollable, updateAllScrollbarWidthAdjustment };

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.