PageSourceSearch

https://graziaandco.com.au/asset/js/1.0.9.6/scrollhide.js

js graziaandco.com.au collected 2026-10-08 01:22:13 UTC 8,982 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkgraziaandco_www=self.webpackChunkgraziaandco_www||[]).push([[548],{542(t,e,s){function r(t){return t.replace(/-([a-z])/g,t=>t[1].toUpperCase())}function n(t=document){return Array.from(t.querySelectorAll(["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])'].join(",")))}s.r(e),s.d(e,{default:()=>l});class o{constructor({eventBus:t,logger:e,router:s}){this.eventBus=t,this.logger=e,this.router=s,this.elements=new WeakMap,this.states=this.elements,this._keys=null}mount(t){if(this.elements.has(t))return this.update(t);const e=this._init(t);this.elements.set(t,e)}update(t){}unmount(t){const e=this.elements.get(t);if(e)try{e.cleanup?.()}finally{this.elements.delete(t)}}destroy(){for(const t of this._elementsKeys())this.unmount(t)}_elementsKeys(){return this._keys||(this._keys=new Set),this._keys}_track(t){this._keys||(this._keys=new Set),this._keys.add(t)}_untrack(t){this._keys?.delete(t)}_init(t){const e=new AbortController;return this._track(t),{cleanup:()=>{e.abort(),this._untrack(t)},controller:e}}getState(t){return this.elements.get(t)}_getDataAttr(t,e,s){return function(t,e,s){const n=e.includes("-")?r(e):e,o=t.dataset[n];return void 0===o?s:"true"===o||"false"!==o&&(isNaN(o)||""===o?o:Number(o))}(t,e,s)}_camelCase(t){return r(t)}_debounce(t,e=300){return function(t,e=300){let s;return function(...r){clearTimeout(s),s=setTimeout(()=>{clearTimeout(s),t.apply(this,r)},e)}}(t,e)}_throttle(t,e=100){return function(t,e=100){let s;return function(...r){s||(t.apply(this,r),s=!0,setTimeout(()=>{s=!1},e))}}(t,e)}_delay(t){return function(t){return new Promise(e=>setTimeout(e,t))}(t)}_getTargetElement(t,e,s={}){const r=`${e}-view`,n=this.getAttr(t,r);if(n){const e=document.querySelector(`[data-view="${n}"]`);return!e&&s.required&&this.logger?.warn(`Target element with data-view="${n}" not found`,{viewName:n,element:t,attribute:r}),e}const o=this.getAttr(t,e);if(!o)return s.required&&this.logger?.warn(`No ${e} or ${r} attribute found`,t),null;const l=document.querySelector(o);return!l&&s.required&&this.logger?.warn("Target element not found",{selector:o,element:t}),l}_getConfigFromAttrs(t,e){const s={};for(const[r,n]of Object.entries(e)){const e=this.constructor.defaults?.[r];s[r]=this.getAttr(t,n,e)}return s}_requireState(t,e="method"){const s=this.getState(t);return s||this.logger?.warn(`${e}: No state found for element`,t),s}_generateId(t="elem"){return function(t="elem"){return`${t}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}(t)}async _waitForTransition(t,e=2e3){return async function(t,e=2e3){return new Promise(s=>{const r=()=>{t.removeEventListener("animationend",r),t.removeEventListener("transitionend",r),s()};t.addEventListener("animationend",r,{once:!0}),t.addEventListener("transitionend",r,{once:!0}),setTimeout(()=>{t.removeEventListener("animationend",r),t.removeEventListener("transitionend",r),s()},e)})}(t,e)}async _fadeIn(t,e=300){return async function(t,e=300){return t.style.opacity="0",t.style.transition=`opacity ${e}ms ease-in-out`,t.offsetHeight,t.style.opacity="1",new Promise(s=>{setTimeout(()=>{t.style.transition="",s()},e)})}(t,e)}async _fadeOut(t,e=300){return async function(t,e=300){return t.style.opacity="1",t.style.transition=`opacity ${e}ms ease-in-out`,t.offsetHeight,t.style.opacity="0",new Promise(s=>{setTimeout(()=>{t.style.transition="",s()},e)})}(t,e)}_getFocusableElements(t=document){return n(t)}_trapFocus(t,e){return function(t,e){const s=n(t);if(!s.length)return;const r=s[0],o=s[s.length-1],l=t.contains(document.activeElement)?document.activeElement:null;!e.shiftKey||l!==r&&l?e.shiftKey||l!==o||(r.focus(),e.preventDefault()):(o.focus(),e.preventDefault())}(t,e)}_restoreFocus(t){return function(t){t&&"function"==typeof t.focus&&requestAnimationFrame(()=>t.focus())}(t)}_createElement(t,e={},s=""){return function(t,e={},s=""){const r=document.createElement(t);for(const[t,s]of Object.entries(e))"className"===t||"class"===t?r.className=s:"style"===t&&"object"==typeof s?Object.assign(r.style,s):"dataset"===t&&"object"==typeof s?Object.assign(r.dataset,s):r.setAttribute(t,s);return"string"==typeof s?r.textContent=s:s instanceof HTMLElement&&r.appendChild(s),r}(t,e,s)}_dispatch(t,e,s){const r=new CustomEvent(e,{detail:s,bubbles:!0,cancelable:!0});return t.dispatchEvent(r),this.eventBus?.emit(e,{element:t,...s}),r}_getSelector(){if(this._selector)return this._selector;const t=this.constructor.name.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return this._selector=`data-${t}`,this._selector}setState(t,e){t.setAttribute(this._getSelector(),e)}getElementState(t){return t.getAttribute(this._getSelector())}setAttr(t,e,s){t.setAttribute(`${this._getSelector()}-${e}`,String(s))}getAttr(t,e,s=null){const r=t.getAttribute(`${this._getSelector()}-${e}`);return null!==r?r:s}removeAttr(t,e){t.removeAttribute(`${this._getSelector()}-${e}`)}hasAttr(t,e){return t.hasAttribute(`${this._getSelector()}-${e}`)}}
1class l extends o{_getSelector(){return"data-scrollhide"}static get defaults(){return{scrollThreshold:50,overlayThreshold:100,scrolledClass:"scrollhide",overlayClass:"scrolloverlay",debounce:16,passive:!0}}_init(t){const e=super._init(t),s=this.getAttr(t,"target"),r=s?document.querySelector(s):t;if(!r)return this.logger?.warn("Scrollhide: Target element not found",{selector:s,element:t}),e;const n=this.getAttr(t,"scroll-threshold",l.defaults.scrollThreshold),o=this.getAttr(t,"overlay-threshold",l.defaults.overlayThreshold),a=this.getAttr(t,"scrolled-class",l.defaults.scrolledClass),i=this.getAttr(t,"overlay-class",l.defaults.overlayClass),c=this.getAttr(t,"debounce",l.defaults.debounce);e.target=r,e.targetSelector=s,e.scrollThreshold=parseInt(n,10),e.overlayThreshold=parseInt(o,10),e.scrolledClass=a,e.overlayClass=i,e.currentY=0,e.lastY=0,e.ticking=!1;const u=this._createScrollHandler(t,e),h=this._throttle(u,c);window.addEventListener("scroll",h,{passive:l.defaults.passive}),e.scrollHandler=h;const d=e.cleanup;return e.cleanup=()=>{window.removeEventListener("scroll",e.scrollHandler),e.animationFrame&&cancelAnimationFrame(e.animationFrame),d()},this._updateElementState(t,e),t.setAttribute("data-scrollhide-enhanced","true"),this.eventBus?.emit("scrollhide:mount",{element:t,target:r,scrollThreshold:e.scrollThreshold,overlayThreshold:e.overlayThreshold,timestamp:performance.now()}),e}_createScrollHandler(t,e){return()=>{e.ticking||(e.animationFrame=requestAnimationFrame(()=>{this._onScroll(t,e),e.ticking=!1}),e.ticking=!0)}}_onScroll(t,e){e.currentY=window.scrollY,this._updateElementState(t,e),e.lastY=e.currentY}_updateElementState(t,e){const{target:s,currentY:r,lastY:n,scrollThreshold:o,overlayThreshold:l,scrolledClass:a,overlayClass:i}=e,c=s.classList.contains(i);r>l&&!c?(s.classList.add(i),this._emitStateChange(t,"overlay-added",{scrollY:r})):r<=l&&c&&(s.classList.remove(i),this._emitStateChange(t,"overlay-removed",{scrollY:r}));const u=s.classList.contains(a);r<=0?u&&(s.classList.remove(a),this._emitStateChange(t,"shown",{scrollY:r,reason:"top"})):r>o&&r>n&&!u?(s.classList.add(a),this._emitStateChange(t,"hidden",{scrollY:r,reason:"scroll-down"})):r<n&&u&&(s.classList.remove(a),this._emitStateChange(t,"shown",{scrollY:r,reason:"scroll-up"}))}_emitStateChange(t,e,s){const r=this.getState(t);this._dispatch(t,`scrollhide:${e}`,{target:r.target,...s}),this.eventBus?.emit(`scrollhide:${e}`,{element:t,target:r.target,timestamp:performance.now(),...s})}show(t){const e=this.getState(t);e&&(e.target.classList.remove(e.scrolledClass),this._emitStateChange(t,"shown",{scrollY:e.currentY,reason:"manual"}))}hide(t){const e=this.getState(t);e&&(e.target.classList.add(e.scrolledClass),this._emitStateChange(t,"hidden",{scrollY:e.currentY,reason:"manual"}))}toggle(t){this.getState(t)&&(this.isHidden(t)?this.show(t):this.hide(t))}isHidden(t){const e=this.getState(t);return!!e&&e.target.classList.contains(e.scrolledClass)}hasOverlay(t){const e=this.getState(t);return!!e&&e.target.classList.contains(e.overlayClass)}getScrollPosition(t){const e=this.getState(t);return e?e.currentY:window.scrollY}updateThresholds(t,{scrollThreshold:e,overlayThreshold:s}){const r=this.getState(t);r&&("number"==typeof e&&(r.scrollThreshold=e),"number"==typeof s&&(r.overlayThreshold=s),this._updateElementState(t,r))}_throttle(t,e){let s=null,r=0;return function(...n){const o=Date.now();o-r>e?(t.apply(this,n),r=o):(clearTimeout(s),s=setTimeout(()=>{t.apply(this,n),r=Date.now()},e-(o-r)))}}getStatus(){const t=document.querySelectorAll('[data-scrollhide-enhanced="true"]');let e=0,s=0;return t.forEach(t=>{this.getState(t)&&(this.isHidden(t)&&e++,this.hasOverlay(t)&&s++)}),{totalElements:t.length,hiddenCount:e,overlayCount:s,currentScrollY:window.scrollY,defaults:l.defaults}}static enhanceAll(t="[data-scrollhide]",e){const s=new l(e);return document.querySelectorAll(t).forEach(t=>{s.mount(t)}),s}}}}]);

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.