PageSourceSearch

https://big-step.co.jp/js/sticky-sidebar.min.js

js big-step.co.jp collected 2026-10-02 17:17:46 UTC 23,108 bytes, 518 lines download raw bytes

1"use strict";
2! function (e, t) {
3  "function" == typeof define && define.amd ? define(t) : "object" == typeof exports ? module.exports = t() : e.ResizeSensor = t()
4}("undefined" != typeof window ? window : this, function () {
5  if ("undefined" == typeof window) return null;
6  var t = "undefined" != typeof window && window.Math == Math ? window : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(),
7    w = t.requestAnimationFrame || t.mozRequestAnimationFrame || t.webkitRequestAnimationFrame || function (e) {
8      return t.setTimeout(e, 20)
9    };
10
11  function o(e, t) {
12    var i = Object.prototype.toString.call(e),
13      n = "[object Array]" === i || "[object NodeList]" === i || "[object HTMLCollection]" === i || "[object Object]" === i || "undefined" != typeof jQuery && e instanceof jQuery || "undefined" != typeof Elements && e instanceof Elements,
14      o = 0,
15      s = e.length;
16    if (n)
17      for (; o < s; o++) t(e[o]);
18    else t(e)
19  }
20
21  function E(e) {
22    if (!e.getBoundingClientRect) return {
23      width: e.offsetWidth,
24      height: e.offsetHeight
25    };
26    var t = e.getBoundingClientRect();
27    return {
28      width: Math.round(t.width),
29      height: Math.round(t.height)
30    }
31  }
32
33  function O(t, i) {
34    Object.keys(i).forEach(function (e) {
35      t.style[e] = i[e]
36    })
37  }
38  var s = function (t, i) {
39    function S() {
40      var i, n, o = [];
41      this.add = function (e) {
42        o.push(e)
43      }, this.call = function (e) {
44        for (i = 0, n = o.length; i < n; i++) o[i].call(this, e)
45      }, this.remove = function (e) {
46        var t = [];
47        for (i = 0, n = o.length; i < n; i++) o[i] !== e && t.push(o[i]);
48        o = t
49      }, this.length = function () {
50        return o.length
51      }
52    }
53
54    function n(i, e) {
55      if (i)
56        if (i.resizedAttached) i.resizedAttached.add(e);
57        else {
58          i.resizedAttached = new S, i.resizedAttached.add(e), i.resizeSensor = document.createElement("div"), i.resizeSensor.dir = "ltr", i.resizeSensor.className = "resize-sensor";
59          var t = {
60              pointerEvents: "none",
61              position: "absolute",
62              left: "0px",
63              top: "0px",
64              right: "0px",
65              bottom: "0px",
66              overflow: "hidden",
67              zIndex: "-1",
68              visibility: "hidden",
69              maxWidth: "100%"
70            },
71            n = {
72              position: "absolute",
73              left: "0px",
74              top: "0px",
75              transition: "0s"
76            };
77          O(i.resizeSensor, t);
78          var o = document.createElement("div");
79          o.className = "resize-sensor-expand", O(o, t);
80          var s = document.createElement("div");
81          O(s, n), o.appendChild(s);
82          var r = document.createElement("div");
83          r.className = "resize-sensor-shrink", O(r, t);
84          var a = document.createElement("div");
85          O(a, n), O(a, {
86            width: "200%",
87            height: "200%"
88          }), r.appendChild(a), i.resizeSensor.appendChild(o), i.resizeSensor.appendChild(r), i.appendChild(i.resizeSensor);
89          var c, d, p = window.getComputedStyle(i),
90            l = p ? p.getPropertyValue("position") : null;
91          "absolute" !== l && "relative" !== l && "fixed" !== l && (i.style.position = "relative");
92          var h = E(i),
93            f = 0,
94            u = 0,
95            v = !0,
96            m = 0,
97            b = function () {
98              if (v) {
99                if (0 === i.offsetWidth && 0 === i.offsetHeight) return void(m = m || w(function () {
100                  m = 0, b()
101                }));
102                v = !1
103              }! function () {
104                var e = i.offsetWidth,
105                  t = i.offsetHeight;
106                s.style.width = e + 10 + "px", s.style.height = t + 10 + "px", o.scrollLeft = e + 10, o.scrollTop = t + 10, r.scrollLeft = e + 10, r.scrollTop = t + 10
107              }()
108            };
109          i.resizeSensor.resetSensor = b;
110          var g = function () {
111              d = 0, c && (f = h.width, u = h.height, i.resizedAttached && i.resizedAttached.call(h))
112            },
113            y = function () {
114              h = E(i), (c = h.width !== f || h.height !== u) && !d && (d = w(g)), b()
115            },
116            T = function (e, t, i) {
117              e.attachEvent ? e.attachEvent("on" + t, i) : e.addEventListener(t, i)
118            };
119          T(o, "scroll", y), T(r, "scroll", y), w(b)
120        }
121    }
122    o(t, function (e) {
123      n(e, i)
124    }), this.detach = function (e) {
125      s.detach(t, e)
126    }, this.reset = function () {
127      t.resizeSensor.resetSensor()
128    }
129  };
130  if (s.reset = function (e) {
131      o(e, function (e) {
132        e.resizeSensor.resetSensor()
133      })
134    }, s.detach = function (e, t) {
135      o(e, function (e) {
136        e && (e.resizedAttached && "function" == typeof t && (e.resizedAttached.remove(t), e.resizedAttached.length()) || e.resizeSensor && (e.contains(e.resizeSensor) && e.removeChild(e.resizeSensor), delete e.resizeSensor, delete e.resizedAttached))
137      })
138    }, "undefined" != typeof MutationObserver) {
139    var i = new MutationObserver(function (e) {
140      for (var t in e)
141        if (e.hasOwnProperty(t))
142          for (var i = e[t].addedNodes, n = 0; n < i.length; n++) i[n].resizeSensor && s.reset(i[n])
143    });
144    document.addEventListener("DOMContentLoaded", function (e) {
145      i.observe(document.body, {
146        childList: !0,
147        subtree: !0
148      })
149    })
150  }
151  return s
152}),
153function (e, t) {
154  "object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t(e.StickySidebar = {})
155}(this, function (e) {
156  "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self;
157  var t, i, n = (function (e, t) {
158      (function (e) {
159        function n(e, t) {
160          for (var i = 0; i < t.length; i++) {
161            var n = t[i];
162            n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n)
163          }
164        }
165        Object.defineProperty(e, "__esModule", {
166          value: !0
167        });
168        var d, o, t = (o = {
169          topSpacing: 0,
170          bottomSpacing: 0,
171          containerSelector: !(d = ".stickySidebar"),
172          innerWrapperSelector: ".inner-wrapper-sticky",
173          stickyClass: "is-affixed",
174          resizeSensor: !0,
175          minWidth: !1
176        }, function (e, t, i) {
177          return t && n(e.prototype, t), i && n(e, i), e
178        }(p, [{
179          key: "initialize",
180          value: function () {
181            var i = this;
182            if (this._setSupportFeatures(), this.options.innerWrapperSelector && (this.sidebarInner = this.sidebar.querySelector(this.options.innerWrapperSelector), null === this.sidebarInner && (this.sidebarInner = !1)), !this.sidebarInner) {
183              var e = document.createElement("div");
184              for (e.setAttribute("class", "inner-wrapper-sticky"), this.sidebar.appendChild(e); this.sidebar.firstChild != e;) e.appendChild(this.sidebar.firstChild);
185              this.sidebarInner = this.sidebar.querySelector(".inner-wrapper-sticky")
186            }
187            if (this.options.containerSelector) {
188              var t = document.querySelectorAll(this.options.containerSelector);
189              if ((t = Array.prototype.slice.call(t)).forEach(function (e, t) {
190                  e.contains(i.sidebar) && (i.container = e)
191                }), !t.length) throw new Error("The container does not contains on the sidebar.")
192            }
193            "function" != typeof this.options.topSpacing && (this.options.topSpacing = parseInt(this.options.topSpacing) || 0), "function" != typeof this.options.bottomSpacing && (this.options.bottomSpacing = parseInt(this.options.bottomSpacing) || 0), this._widthBreakpoint(), this.calcDimensions(), this.stickyPosition(), this.bindEvents(), this._initialized = !0
194          }
195        }, {
196          key: "bindEvents",
197          value: function () {
198            window.addEventListener("resize", this, {
199              passive: !0,
200              capture: !1
201            }), window.addEventListener("scroll", this, {
202              passive: !0,
203              capture: !1
204            }), this.sidebar.addEventListener("update" + d, this), this.options.resizeSensor && "undefined" != typeof ResizeSensor && (new ResizeSensor(this.sidebarInner, this.handleEvent), new ResizeSensor(this.container, this.handleEvent))
205          }
206        }, {
207          key: "handleEvent",
208          value: function (e) {
209            this.updateSticky(e)
210          }
211        }, {
212          key: "calcDimensions",
213          value: function () {
214            if (!this._breakpoint) {
215              var e = this.dimensions;
216              e.containerTop = p.offsetRelative(this.container).top, e.containerHeight = this.container.clientHeight, e.containerBottom = e.containerTop + e.containerHeight, e.sidebarHeight = this.sidebarInner.offsetHeight, e.sidebarWidth = this.sidebarInner.offsetWidth, e.viewportHeight = window.innerHeight, e.maxTranslateY = e.containerHeight - e.sidebarHeight, this._calcDimensionsWithScroll()
217            }
218          }
219        }, {
220          key: "_calcDimensionsWithScroll",
221          value: function () {
222            var e = this.dimensions;
223            e.sidebarLeft = p.offsetRelative(this.sidebar).left, e.viewportTop = document.documentElement.scrollTop || document.body.scrollTop, e.viewportBottom = e.viewportTop + e.viewportHeight, e.viewportLeft = document.documentElement.scrollLeft || document.body.scrollLeft, e.topSpacing = this.options.topSpacing, e.bottomSpacing = this.options.bottomSpacing, "function" == typeof e.topSpacing && (e.topSpacing = parseInt(e.topSpacing(this.sidebar)) || 0), "function" == typeof e.bottomSpacing && (e.bottomSpacing = parseInt(e.bottomSpacing(this.sidebar)) || 0), "VIEWPORT-TOP" === this.affixedType ? e.topSpacing < e.lastTopSpacing && (e.translateY += e.lastTopSpacing - e.topSpacing, this._reStyle = !0) : "VIEWPORT-BOTTOM" === this.affixedType && e.bottomSpacing < e.lastBottomSpacing && (e.translateY += e.lastBottomSpacing - e.bottomSpacing, this._reStyle = !0), e.lastTopSpacing = e.topSpacing, e.lastBottomSpacing = e.bottomSpacing
224          }
225        }, {
226          key: "isSidebarFitsViewport",
227          value: function () {
228            var e = this.dimensions,
229              t = "down" === this.scrollDirection ? e.lastBottomSpacing : e.lastTopSpacing;
230            return this.dimensions.sidebarHeight + t < this.dimensions.viewportHeight
231          }
232        }, {
233          key: "observeScrollDir",
234          value: function () {
235            var e = this.dimensions;
236            if (e.lastViewportTop !== e.viewportTop) {
237              var t = "down" === this.direction ? Math.min : Math.max;
238              e.viewportTop === t(e.viewportTop, e.lastViewportTop) && (this.direction = "down" === this.direction ? "up" : "down")
239            }
240          }
241        }, {
242          key: "getAffixType",
243          value: function () {
244            this._calcDimensionsWithScroll();
245            var e = this.dimensions,
246              t = e.viewportTop + e.topSpacing,
247              i = this.affixedType;
248            return i = t <= e.containerTop || e.containerHeight <= e.sidebarHeight ? (e.translateY = 0, "STATIC") : "up" === this.direction ? this._getAffixTypeScrollingUp() : this._getAffixT
vendor: 4,154 bytes, lines 248-340
248ypeScrollingDown(), e.translateY = Math.max(0, e.translateY), e.translateY = Math.min(e.containerHeight, e.translateY), e.translateY = Math.round(e.translateY), e.lastViewportTop = e.viewportTop, i
249          }
250        }, {
251          key: "_getAffixTypeScrollingDown",
252          value: function () {
253            var e = this.dimensions,
254              t = e.sidebarHeight + e.containerTop,
255              i = e.viewportTop + e.topSpacing,
256              n = e.viewportBottom - e.bottomSpacing,
257              o = this.affixedType;
258            return this.isSidebarFitsViewport() ? e.sidebarHeight + i >= e.containerBottom ? (e.translateY = e.containerBottom - t, o = "CONTAINER-BOTTOM") : i >= e.containerTop && (e.translateY = i - e.containerTop, o = "VIEWPORT-TOP") : e.containerBottom <= n ? (e.translateY = e.containerBottom - t, o = "CONTAINER-BOTTOM") : t + e.translateY <= n ? (e.translateY = n - t, o = "VIEWPORT-BOTTOM") : e.containerTop + e.translateY <= i && 0 !== e.translateY && e.maxTranslateY !== e.translateY && (o = "VIEWPORT-UNBOTTOM"), o
259          }
260        }, {
261          key: "_getAffixTypeScrollingUp",
262          value: function () {
263            var e = this.dimensions,
264              t = e.sidebarHeight + e.containerTop,
265              i = e.viewportTop + e.topSpacing,
266              n = e.viewportBottom - e.bottomSpacing,
267              o = this.affixedType;
268            return i <= e.translateY + e.containerTop ? (e.translateY = i - e.containerTop, o = "VIEWPORT-TOP") : e.containerBottom <= n ? (e.translateY = e.containerBottom - t, o = "CONTAINER-BOTTOM") : this.isSidebarFitsViewport() || e.containerTop <= i && 0 !== e.translateY && e.maxTranslateY !== e.translateY && (o = "VIEWPORT-UNBOTTOM"), o
269          }
270        }, {
271          key: "_getStyle",
272          value: function (e) {
273            if (void 0 !== e) {
274              var t = {
275                  inner: {},
276                  outer: {}
277                },
278                i = this.dimensions;
279              switch (e) {
280              case "VIEWPORT-TOP":
281                t.inner = {
282                  position: "fixed",
283                  top: i.topSpacing,
284                  left: i.sidebarLeft - i.viewportLeft,
285                  width: i.sidebarWidth
286                };
287                break;
288              case "VIEWPORT-BOTTOM":
289                t.inner = {
290                  position: "fixed",
291                  top: "auto",
292                  left: i.sidebarLeft,
293                  bottom: i.bottomSpacing,
294                  width: i.sidebarWidth
295                };
296                break;
297              case "CONTAINER-BOTTOM":
298              case "VIEWPORT-UNBOTTOM":
299                var n = this._getTranslate(0, i.translateY + "px");
300                t.inner = n ? {
301                  transform: n
302                } : {
303                  position: "absolute",
304                  top: i.translateY,
305                  width: i.sidebarWidth
306                }
307              }
308              switch (e) {
309              case "VIEWPORT-TOP":
310              case "VIEWPORT-BOTTOM":
311              case "VIEWPORT-UNBOTTOM":
312              case "CONTAINER-BOTTOM":
313                t.outer = {
314                  height: i.sidebarHeight,
315                  position: "relative"
316                }
317              }
318              return t.outer = p.extend({
319                height: "",
320                position: ""
321              }, t.outer), t.inner = p.extend({
322                position: "relative",
323                top: "",
324                left: "",
325                bottom: "",
326                width: "",
327                transform: ""
328              }, t.inner), t
329            }
330          }
331        }, {
332          key: "stickyPosition",
333          value: function (e) {
334            if (!this._breakpoint) {
335              e = this._reStyle || e || !1, this.options.topSpacing, this.options.bottomSpacing;
336              var t = this.getAffixType(),
337                i = this._getStyle(t);
338              if ((this.affixedType != t || e) && t) {
339                var n = "affix." + t.toLowerCase().replace("viewport-", "") + d;
340                for (var o in p.eventTrigger(this.sidebar, n), "
340STATIC" === t ? p.removeClass(this.sidebar, this.options.stickyClass) : p.addClass(this.sidebar, this.options.stickyClass), i.outer) {
341                  var s = "number" == typeof i.outer[o] ? "px" : "";
342                  this.sidebar.style[o] = i.outer[o] + s
343                }
344                for (var r in i.inner) {
345                  var a = "number" == typeof i.inner[r] ? "px" : "";
346                  this.sidebarInner.style[r] = i.inner[r] + a
347                }
348                var c = "affixed." + t.toLowerCase().replace("viewport-", "") + d;
349                p.eventTrigger(this.sidebar, c)
350              } else this._initialized && (this.sidebarInner.style.left = i.inner.left);
351              this.affixedType = t
352            }
353          }
354        }, {
355          key: "_widthBreakpoint",
356          value: function () {
357            window.innerWidth <= this.options.minWidth ? (this._breakpoint = !0, this.affixedType = "STATIC", this.sidebar.removeAttribute("style"), p.removeClass(this.sidebar, this.options.stickyClass), this.sidebarInner.removeAttribute("style")) : this._breakpoint = !1
358          }
359        }, {
360          key: "updateSticky",
361          value: function (e) {
362            var t, i = this,
363              n = 0 < arguments.length && void 0 !== e ? e : {};
364            this._running || (this._running = !0, t = n.type, requestAnimationFrame(function () {
365              switch (t) {
366              case "scroll":
367                i._calcDimensionsWithScroll(), i.observeScrollDir(), i.stickyPosition();
368                break;
369              case "resize":
370              default:
371                i._widthBreakpoint(), i.calcDimensions(), i.stickyPosition(!0)
372              }
373              i._running = !1
374            }))
375          }
376        }, {
377          key: "_setSupportFeatures",
378          value: function () {
379            var e = this.support;
380            e.transform = p.supportTransform(), e.transform3d = p.supportTransform(!0)
381          }
382        }, {
383          key: "_getTranslate",
384          value: function (e, t, i) {
385            var n = 0 < arguments.length && void 0 !== e ? e : 0,
386              o = 1 < arguments.length && void 0 !== t ? t : 0,
387              s = 2 < arguments.length && void 0 !== i ? i : 0;
388            return this.support.transform3d ? "translate3d(" + n + ", " + o + ", " + s + ")" : !!this.support.translate && "translate(" + n + ", " + o + ")"
389          }
390        }, {
391          key: "destroy",
392          value: function () {
393            window.removeEventListener("resize", this, {
394              capture: !1
395            }), window.removeEventListener("scroll", this, {
396              capture: !1
397            }), this.sidebar.classList.remove(this.options.stickyClass), this.sidebar.style.minHeight = "", this.sidebar.removeEventListener("update" + d, this);
398            var e = {
399              inner: {},
400              outer: {}
401            };
402            for (var t in e.inner = {
403                position: "",
404                top: "",
405                left: "",
406                bottom: "",
407                width: "",
408                transform: ""
409              }, e.outer = {
410                height: "",
411                position: ""
412              }, e.outer) this.sidebar.style[t] = e.outer[t];
413            for (var i in e.inner) this.sidebarInner.style[i] = e.inner[i];
414            this.options.resizeSensor && "undefined" != typeof ResizeSensor && (ResizeSensor.detach(this.sidebarInner, this.handleEvent), ResizeSensor.detach(this.container, this.handleEvent))
415          }
416        }], [{
417          key: "supportTransform",
418          value: function (e) {
419            var i = !1,
420              t = e ? "perspective" : "transform",
421              n = t.charAt(0).toUpperCase() + t.slice(1),
422              o = document.createElement("support").style;
423            return (t + " " + ["Webkit", "Moz", "O", "ms"].join(n + " ") + n).split(" ").forEach(function (e, t) {
424              if (void 0 !== o[e]) return i = e, !1
425            }), i
426          }
427        }, {
428          key: "eventTrigger",
429          value: function (e, t, i) {
430            try {
431              var n = new CustomEvent(t, {
432                detail: i
433              })
434            } catch (e) {
435              (n = document.createEvent("CustomEvent")).initCustomEvent(t, !0, !0, i)
436            }
437            e.dispatchEvent(n)
438          }
439        }, {
440          key: "extend",
441          value: function (e, t) {
442            var i = {};
443            for (var n in e) void 0 !== t[n] ? i[n] = t[n] : i[n] = e[n];
444            return i
445          }
446        }, {
447          key: "offsetRelative",
448          value: function (e) {
449            var t = {
450              left: 0,
451              top: 0
452            };
453            do {
454              var i = e.offsetTop,
455                n = e.offsetLeft;
456              isNaN(i) || (t.top += i), isNaN(n) || (t.left += n), e = "BODY" === e.tagName ? e.parentElement : e.offsetParent
457            } while (e);
458            return t
459          }
460        }, {
461          key: "addClass",
462          value: function (e, t) {
463            p.hasClass(e, t) || (e.classList ? e.classList.add(t) : e.className += " " + t)
464          }
465        }, {
466          key: "removeClass",
467          value: function (e, t) {
468            p.hasClass(e, t) && (e.classList ? e.classList.remove(t) : e.className = e.className.replace(new RegExp("(^|\\b)" + t.split(" ").join("|") + "(\\b|$)", "gi"), " "))
469          }
470        }, {
471          key: "hasClass",
472          value: function (e, t) {
473            return e.classList ? e.classList.contains(t) : new RegExp("(^| )" + t + "( |$)", "gi").test(e.className)
474          }
475        }, {
476          key: "defaults",
477          get: function () {
478            return o
479          }
480        }]), p);
481
482        function p(e) {
483          var t = this,
484            i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
485          if (function (e, t) {
486              if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
487            }(this, p), this.options = p.extend(o, i), this.sidebar = "string" == typeof e ? document.querySelector(e) : e, void 0 === this.sidebar) throw new Error("There is no specific sidebar element.");
488          this.sidebarInner = !1, this.container = this.sidebar.parentElement, this.affixedType = "STATIC", this.direction = "down", this.support = {
489            transform: !1,
490            transform3d: !1
491          }, this._initialized = !1, this._reStyle = !1, this._breakpoint = !1, this.dimensions = {
492            translateY: 0,
493            maxTranslateY: 0,
494            topSpacing: 0,
495            lastTopSpacing: 0,
496            bottomSpacing: 0,
497            lastBottomSpacing: 0,
498            sidebarHeight: 0,
499            sidebarWidth: 0,
500            containerTop: 0,
501            containerHeight: 0,
502            viewportHeight: 0,
503            viewportTop: 0,
504            lastViewportTop: 0
505          }, ["handleEvent"].forEach(function (e) {
506            t[e] = t[e].bind(t)
507          }), this.initialize()
508        }
509        e.default = t, window.StickySidebar = t
510      })(t)
511    }(t = {
512      exports: {}
513    }, t.exports), t.exports),
514    o = (i = n) && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
515  e.default = o, e.__moduleExports = n, Object.defineProperty(e, "__esModule", {
516    value: !0
517  })
518});

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.