1/** @type {HTMLElement} rootElm - ããã¥ã¡ã³ãã®ã«ã¼ãè¦ç´ (= htmlè¦ç´ ). */ 2const rootElm = document.documentElement; 3 4/** @type {Element} - ããã¥ã¡ã³ãã®bodyè¦ç´ . */ 5const bodyElm = document.body; 6 7/** @type {number} screenWidthView - ç»é¢å¹ (viewport). */ 8let screenWidthView = window.innerWidth; 9 10/** @type {number} MOBILE_SCREEN_WIDTH - ã¢ãã¤ã«ããã¤ã¹ãå¤å®ããç»é¢å¹ . */ 11const MOBILE_SCREEN_WIDTH = 768; 12 13/** @type {string} SCROLL_STATE_STRING_CLASS - ã¹ã¯ãã¼ã«ãåºå®ããCSSã®ã¯ã©ã¹å. */ 14const SCROLL_STATE_STRING_CLASS = "is-fixed"; 15 16/* 17 ! âã®ã¹ã¿ã¤ã«ã使ç¨ãã¦ãã ãã ! 18 19 html { 20 overflow-y: scroll; // MEMO: ã¹ã¯ãã¼ã«åºå®æã®ã¬ã¿ã¼å¦ç 21 22 &[data-scroll-fixed=active] { 23 overflow: hidden; 24 } 25 } 26 27 body { 28 width: 100%; 29 30 &.is-fixed { 31 position: fixed; 32 left: 0; 33 } 34 } 35*/ 36 37 38 39 40/** 41 * ã¹ã¯ãã¼ã«åºå®ãæå¹åãã. 42 * 43 * @returns {void} 44 */ 45export function fixedBodyOn() { 46 if (screenWidthView < MOBILE_SCREEN_WIDTH) { 47 // ã¢ãã¤ã«ç«¯æ«ã®ã¹ã¯ãã¼ã«åºå®æã¯ã¹ã¯ãã¼ã«ãã¼ãèæ ®ããå¿ è¦ã¯ãªããããoverflow: hidden;ã®åãæ¿ãã ãã§ok. 48 rootElm.setAttribute("data-scroll-fixed", "active"); 49 50 } else { 51 /** @type {number} bodyOffsetY - ç¾å¨ã®ã¹ã¯ãã¼ã«ä½ç½®. */ 52 const bodyOffsetY = window.scrollY; 53 54 bodyElm.style.top = `${-bodyOffsetY}px`; 55 bodyElm.classList.add(SCROLL_STATE_STRING_CLASS); 56 } 57} 58 59 60 61/** 62 * ã¹ã¯ãã¼ã«åºå®ãç¡å¹åãã. 63 * 64 * @returns {void} 65 */ 66export function fixedBodyOff() { 67 rootElm.style.scrollBehavior = "auto"; 68 69 if (screenWidthView < MOBILE_SCREEN_WIDTH) { 70 // ã¢ãã¤ã«ç«¯æ«ã®ã¹ã¯ãã¼ã«åºå®æã¯ã¹ã¯ãã¼ã«ãã¼ãèæ ®ããå¿ è¦ã¯ãªããããoverflow: hidden;ã®åãæ¿ãã ãã§ok. 71 rootElm.setAttribute("data-scroll-fixed", ""); 72 73 } else { 74 /** @type {number} offsetY - <body>è¦ç´ ã«ä»ä¸ããã¦ããã¹ã¯ãã¼ã«åºå®ä½ç½®. */ 75 const offsetY = bodyElm.style.top ? Number(bodyElm.style.top.replace("-", "").replace("px", "")) : 0; 76 77 bodyElm.classList.remove(SCROLL_STATE_STRING_CLASS); 78 window.scrollTo(0, offsetY); // position: fixed; è§£é¤å¾ã«ãã¼ã¸ãããã¸é·ç§»ãã¦ãã¾ãã®ãé²ãããã«å¿ è¦. 79 bodyElm.style.top = ""; 80 } 81 82 rootElm.style.scrollBehavior = ""; 83}
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.