PageSourceSearch

https://i-shift.com/wp-content/themes/OriginalTheme/asset/js/smooth-scroll.js

js i-shift.com collected 2026-10-09 22:40:37 UTC 1,402 bytes, 52 lines download raw bytes

1jQuery(function ($) {
2
3  const normPath = (p) => (p || "").replace(/\/$/, "");
4
5  const getStopOffset = () => {
6    const navH = $("#nav-fixed").outerHeight() || 0;
7
8    const isSP = window.matchMedia("(max-width: 768px)").matches;
9
10    // SP:8vh / PC:5vh(元コードのまま)
11    const vh = isSP
12      ? window.innerHeight * 0.08
13      : window.innerHeight * 0.05;
14
15    return navH + vh;
16  };
17
18  // ★後から生成されるリンクも拾えるように「委譲」
19  $(document).on("click", "a[href*='#']", function (e) {
20
21    const targetId = this.hash;
22    if (!targetId || targetId === "#") return;
23
24    // 同一ページだけ対象(末尾スラッシュ差を吸収)
25    if (normPath(window.location.pathname) !== normPath(this.pathname)) return;
26
27    const $target = $(targetId);
28    if (!$target.length) return;
29
30    // ★ブラウザ標準ジャンプを先に止める
31    e.preventDefault();
32
33    // ★連打などでガタつかないように止める
34    $("html, body").stop(true, false);
35
36    const position = $target.offset().top - getStopOffset();
37
38    $("html, body").animate({
39        scrollTop: position
40      },
41      1000,
42      "swing",
43      function () {
44        // ★URLに # を反映(標準ジャンプは起こさない)
45        if (history && history.pushState) {
46          history.pushState(null, "", targetId);
47        }
48      }
49    );
50  });
51
52});

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.