PageSourceSearch

https://oyaschool.com/wp-content/themes/oyaschool/js/new-sticky.js?ver=6.3.10

js oyaschool.com collected 2026-09-25 09:11:36 UTC 28,297 bytes, 703 lines download raw bytes

1/**
2 * sticky-sidebar - A JavaScript plugin for making smart and high performance.
3 * @version v3.3.1
4 * @link https://github.com/abouolia/sticky-sidebar
5 * @author Ahmed Bouhuolia
6 * @license The MIT License (MIT)
7 **/
8!(function(t, e) {
9  "object" == typeof exports && "undefined" != typeof module
10    ? (module.exports = e())
11    : "function" == typeof define && define.amd
12    ? define(e)
13    : (t.StickySidebar = e());
14})(this, function() {
15  "use strict";
16  "undefined" != typeof window
17    ? window
18    : "undefined" != typeof global
19    ? global
20    : "undefined" != typeof self && self;
21  function t(t) {
22    return t &&
23      t.__esModule &&
24      Object.prototype.hasOwnProperty.call(t, "default")
25      ? t.default
26      : t;
27  }
28  function e(t, e) {
29    return t((e = { exports: {} }), e.exports), e.exports;
30  }
31  var i = e(function(t, e) {
32    (function(t) {
33      Object.defineProperty(t, "__esModule", { value: !0 });
34      var l,
35        n,
36        e = (function() {
37          function n(t, e) {
38            for (var i = 0; i < e.length; i++) {
39              var n = e[i];
40              (n.enumerable = n.enumerable || !1),
41                (n.configurable = !0),
42                "value" in n && (n.writable = !0),
43                Object.defineProperty(t, n.key, n);
44            }
45          }
46          return function(t, e, i) {
47            return e && n(t.prototype, e), i && n(t, i), t;
48          };
49        })(),
50        i = ((l = ".stickySidebar"),
51        (n = {
52          topSpacing: 0,
53          bottomSpacing: 0,
54          containerSelector: !1,
55          innerWrapperSelector: ".inner-wrapper-sticky",
56          stickyClass: "is-affixed",
57          resizeSensor: !0,
58          minWidth: !1
59        }),
60        (function() {
61          function c(t) {
62            var e = this,
63              i =
64                1 < arguments.length && void 0 !== arguments[1]
65                  ? arguments[1]
66                  : {};
67            if (
68              ((function(t, e) {
69                if (!(t instanceof e))
70                  throw new TypeError("Cannot call a class as a function");
71              })(this, c),
72              (this.options = c.extend(n, i)),
73              (this.sidebar =
74                "string" == typeof t ? document.querySelector(t) : t),
75              void 0 === this.sidebar)
76            )
77              throw new Error("There is no specific sidebar element.");
78            (this.sidebarInner = !1),
79              (this.container = this.sidebar.parentElement),
80              (this.affixedType = "STATIC"),
81              (this.direction = "down"),
82              (this.support = { transform: !1, transform3d: !1 }),
83              (this._initialized = !1),
84              (this._reStyle = !1),
85              (this._breakpoint = !1),
86              (this.dimensions = {
87                translateY: 0,
88                maxTranslateY: 0,
89                topSpacing: 0,
90                lastTopSpacing: 0,
91                bottomSpacing: 0,
92                lastBottomSpacing: 0,
93                sidebarHeight: 0,
94                sidebarWidth: 0,
95                containerTop: 0,
96                containerHeight: 0,
97                viewportHeight: 0,
98                viewportTop: 0,
99                lastViewportTop: 0
100              }),
101              ["handleEvent"].forEach(function(t) {
102                e[t] = e[t].bind(e);
103              }),
104              this.initialize();
105          }
106          return (
107            e(
108              c,
109              [
110                {
111                  key: "initialize",
112                  value: function() {
113                    var i = this;
114                    if (
115                      (this._setSupportFeatures(),
116                      this.options.innerWrapperSelector &&
117                        ((this.sidebarInner = this.sidebar.querySelector(
118                          this.options.innerWrapperSelector
119                        )),
120                        null === this.sidebarInner && (this.sidebarInner = !1)),
121                      !this.sidebarInner)
122                    ) {
123                      var t = document.createElement("div");
124                      for (
125                        t.setAttribute("class", "inner-wrapper-sticky"),
126                          this.sidebar.appendChild(t);
127                        this.sidebar.firstChild != t;
128
129                      )
130                        t.appendChild(this.sidebar.firstChild);
131                      this.sidebarInner = this.sidebar.querySelector(
132                        ".inner-wrapper-sticky"
133                      );
134                    }
135                    if (this.options.containerSelector) {
136                      var e = document.querySelectorAll(
137                        this.options.containerSelector
138                      );
139                      if (
140                        ((e = Array.prototype.slice.call(e)).forEac
140h(function(
141                          t,
142                          e
143                        ) {
144                          t.contains(i.sidebar) && (i.container = t);
145                        }),
146                        !e.length)
147                      )
148                        throw new Error(
149                          "The container does not contains on the sidebar."
150                        );
151                    }
152                    "function" != typeof this.options.topSpacing &&
153                      (this.options.topSpacing =
154                        parseInt(this.options.topSpacing) || 0),
155                      "function" != typeof this.options.bottomSpacing &&
156                        (this.options.bottomSpacing =
157                          parseInt(this.options.bottomSpacing) || 0),
158                      this._widthBreakpoint(),
159                      this.calcDimensions(),
160                      this.stickyPosition(),
161                      this.bindEvents(),
162                      (this._initialized = !0);
163                  }
164                },
165                {
166                  key: "bindEvents",
167                  value: function() {
168                    window.addEventListener("resize", this, {
169                      passive: !0,
170                      capture: !1
171                    }),
172                      window.addEventListener("scroll", this, {
173                        passive: !0,
174                        capture: !1
175                      }),
176                      this.sidebar.addEventListener("update" + l, this),
177                      this.options.resizeSensor &&
178                        "undefined" != typeof ResizeSensor &&
179                        (new ResizeSensor(this.sidebarInner, this.handleEvent),
180                        new ResizeSensor(this.container, this.handleEvent));
181                  }
182                },
183                {
184                  key: "handleEvent",
185                  value: function(t) {
186                    this.updateSticky(t);
187                  }
188                },
189                {
190                  key: "calcDimensions",
191                  value: function() {
192                    if (!this._breakpoint) {
193                      var t = this.dimensions;
194                      (t.containerTop = c.offsetRelative(this.container).top),
195                        (t.containerHeight = this.container.clientHeight),
196                        (t.containerBottom =
197                          t.containerTop + t.containerHeight),
198                        (t.sidebarHeight = this.sidebarInner.offsetHeight),
199                        (t.sidebarWidth = this.sidebarInner.offsetWidth),
200                        (t.viewportHeight = window.innerHeight),
201                        (t.maxTranslateY = t.containerHeight - t.sidebarHeight),
202                        this._calcDimensionsWithScroll();
203                    }
204                  }
205                },
206                {
207                  key: "_calcDimensionsWithScroll",
208                  value: function() {
209                    var t = this.dimensions;
210                    (t.sidebarLeft = c.offsetRelative(this.sidebar).left),
211                      (t.viewportTop =
212                        document.documentElement.scrollTop ||
213                        document.body.scrollTop),
214                      (t.viewportBottom = t.viewportTop + t.viewportHeight),
215                      (t.viewportLeft =
216                        document.documentElement.scrollLeft ||
217                        document.body.scrollLeft),
218                      (t.topSpacing = this.options.topSpacing),
219                      (t.bottomSpacing = this.options.bottomSpacing),
220                      "function" == typeof t.topSpacing &&
221                        (t.topSpacing =
222                          parseInt(t.topSpacing(this.sidebar)) || 0),
223                      "function" == typeof t.bottomSpacing &&
224                        (t.bottomSpacing =
225                          parseInt(t.bottomSpacing(this.sidebar)) || 0),
226                      "VIEWPORT-TOP" === this.affixedType
227                        ? t.topSpacing < t.lastTopSpacing &&
228                          ((t.translateY += t.lastTopSpacing - t.topSpacing),
229                          (this._reStyle = !0))
230                        : "VIEWPORT-BOTTOM" === this.affixedType &&
231                          t.bottomSpacing < t.lastBottomSpacing &&
232                          ((t.translateY +=
233                            t.lastBottomSpacing - t.bottomSpacing),
234                          (this._reStyle = !0)),
235                      (t.lastTopSpacing = t.topSpacing),
236                      (t.lastBottomSpacing = t.bottomSpacing);
237                  }
238                },
239                {
240                  key: "isSidebarFitsViewport",
241                  value: function() {
242                    var t = this.dimensions,
243                      e =
244                        "down" === this.scrollDirection
245                          ? t.lastBottomSpacing
246                          : t.lastTopSpacing;
247                    return (
248                      this.dimensions.sidebarHeight + e <
249                      this.dimensions.viewportHeight
250                    );
251                  }
252                },
253                {
254                  key: "observeScrollDir",
255                  value: function() {
256                    var t = this.dimensions;
257                    if (t.lastViewportTop !== t.viewportTop) {
258                      var e = "down" === this.direction ? Math.min : Math.max;
259                      t.viewportTop === e(t.viewportTop, t.lastViewportTop) &&
260                        (this.direction =
261                          "down" === this.direction ? "up" : "down");
262                    }
263                  }
264                },
265                {
266                  key: "getAffixType",
267                  value: function() {
268                    this._calcDimensionsWithScroll();
269                    var t = this.dimensions,
270                      e = t.viewportTop + t.topSpacing,
271                      i = this.affixedType;
272                    return (
273                      e <= t.containerTop ||
274                      t.containerHeight <= t.sidebarHeight
275                        ? ((t.translateY = 0), (i = "STATIC"))
276                        : (i =
277                            "up" === this.direction
278                              ? this._getAffixTypeScrollingUp()
279                              : this._getAffixTypeScrollingDown()),
280                      (t.translateY = Math.max(0, t.translateY)),
281                      (t.translateY = Math.min(
282                        t.containerHeight,
283                        t.translateY
284                      )),
285                      (t.translateY = Math.round(t.translateY)),
286                      (t.lastViewportTop = t.viewportTop),
287                      i
288                    );
289                  }
290                },
291                {
292                  key: "_getAffixTypeScrollingDown",
293                  value: function() {
294                    var t = this.dimensions,
295                      e = t.sidebarHeight + t.containerTop,
296                      i = t.viewportTop + t.topSpacing,
297                      n = t.viewportBottom - t.bottomSpacing,
298                      o = this.affixedType;
299                    return (
300                      this.isSidebarFitsViewport()
301                        ? t.sidebarHeight + i >= t.containerBottom
302                          ? ((t.translateY = t.containerBottom - e),
303                            (o = "CONTAINER-BOTTOM"))
304                          : i >= t.containerTop &&
305                            ((t.translateY = i - t.containerTop),
306                            (o = "VIEWPORT-TOP"))
307                        : t.containerBottom <= n
308                        ? ((t.translateY = t.containerBottom - e),
309                          (o = "CONTAINER-BOTTOM"))
310                        : e + t.translateY <= n
311                        ? ((t.translateY = n - e), (o = "VIEWPORT-BOTTOM"))
312                        : t.containerTop + t.translateY <= i &&
313                          0 !== t.translateY &&
314                          t.maxTranslateY !== t.translateY &&
315                          (o = "VIEWPORT-UNBOTTOM"),
316                      o
317                    );
318                  }
319                },
320                {
321                  key: "_getAffixTypeScrollingUp",
322                  value: function() {
323                    var t = this.dimensions,
324                      e = t.sidebarHeight + t.containerTop,
325                      i = t.viewportTop + t.topSpacing,
326                      n = t.viewportBottom - t.bottomSpacing,
327                      o = this.affixedType;
328                    return (
329                      i <= t.translateY + t.containerTop
330                        ? ((t.translateY = i - t.containerTop),
331                          (o = "VIEWPORT-TOP"))
332                        : t.containerBottom <= n
333                        ? ((t.translateY = t.containerBottom - e),
334                          (o = "CONTAINER-BOTTOM"))
335                        : this.isSidebarFitsViewport() ||
336                          (t.containerTop <= i &&
337                            0 !== t.translateY &&
338                            t.maxTranslateY !== t.translateY &&
339                            (o = "VIEWPORT-UNBOTTOM")),
340                      o
341                    );
342                  }
343                },
344                {
345                  key: "_getStyle",
346                  value: function(t) {
347                    if (void 0 !== t) {
348                      var e = { inner: {}, outer: {} },
349                        i = this.dimensions;
350                      switch (t) {
351                        case "VIEWPORT-TOP":
352                          e.inner = {
353                            position: "fixed",
354                            top: i.topSpacing,
355                            left: i.sidebarLeft - i.viewportLeft,
356                            width: i.sidebarWidth
357                          };
358                          break;
359                        case "VIEWPORT-BOTTOM":
360                          e.inner = {
361                            position: "fixed",
362                            top: "auto",
363                            left: i.sidebarLeft,
364                            bottom: i.bottomSpacing,
365                            width: i.sidebarWidth
366                          };
367                          break;
368                        case "CONTAINER-BOTTOM":
369                        case "VIEWPORT-UNBOTTOM":
370                          var n = this._getTranslate(0, i.translateY + "px");
371                          e.inner = n
372                            ? { transform: n }
373                            : {
374                                position: "absolute",
375                                top: i.translateY,
376                                width: i.sidebarWidth
377                              };
378                      }
379                      switch (t) {
380                        case "VIEWPORT-TOP":
381                        case "VIEWPORT-BOTTOM":
382                        case "VIEWPORT-UNBOTTOM":
383                        case "CONTAINER-BOTTOM":
384                          e.outer = {
385                            height: i.sidebarHeight,
386                            position: "relative"
387                          };
388                      }
389                      return (
390                        (e.outer = c.extend(
391                          { height: "", position: "" },
392                          e.outer
393                        )),
394                        (e.inner = c.extend(
395                          {
396                            position: "relative",
397                            top: "",
398                            left: "",
399                            bottom: "",
400                            width: "",
401                            transform: ""
402                          },
403                          e.inner
404                        )),
405                        e
406                      );
407                    }
408                  }
409                },
410                {
411                  key: "stickyPosition",
412                  value: function(t) {
413                    if (!this._breakpoint) {
414                      (t = this._reStyle || t || !1),
415                        this.options.topSpacing,
416                        this.options.bottomSpacing;
417                      var e = this.getAffixType(),
418                        i = this._getStyle(e);
419                      if ((this.affixedType != e || t) && e) {
420                        var n =
421                          "affix." +
422                          e.toLowerCase().replace("viewport-", "") +
423                          l;
424                        for (var o in (c.eventTrigger(this.sidebar, n),
425                        "STATIC" === e
426                          ? c.removeClass(
427                              this.sidebar,
428                              this.options.stickyClass
429                            )
430                          : c.addClass(this.sidebar, this.options.stickyClass),
431                        i.outer)) {
432                          var s = "number" == typeof i.outer[o] ? "px" : "";
433                          this.sidebar.style[o] = i.outer[o] + s;
434                        }
435                        for (var r in i.inner) {
436                          var a = "number" == typeof i.inner[r] ? "px" : "";
437                          this.sidebarInner.style[r] = i.inner[r] + a;
438                        }
439                        var p =
440                          "affixed." +
441                          e.toLowerCase().replace("viewport-", "") +
442                          l;
443                        c.eventTrigger(this.sidebar, p);
444                      } else
445                        this._initialized &&
446                          (this.sidebarInner.style.left = i.inner.left);
447                      this.affixedType = e;
448                    }
449                  }
450                },
451                {
452                  key: "_widthBreakpoint",
453                  value: function() {
454                    window.innerWidth <= this.options.minWidth
455                      ? ((this._breakpoint = !0),
456                        (this.affixedType = "STATIC"),
457                        this.sidebar.removeAttribute("style"),
458                        c.removeClass(this.sidebar, this.options.stickyClass),
459                        this.sidebarInner.removeAttribute("style"))
460                      : (this._breakpoint = !1);
461                  }
462                },
463                {
464                  key: "updateSticky",
465                  value: function() {
466                    var t,
467                      e = this,
468                      i =
469                        0 < arguments.length && void 0 !== arguments[0]
470                          ? arguments[0]
471                          : {};
472                    this._running ||
473                      ((this._running = !0),
474                      (t = i.type),
475                      requestAnimationFrame(function() {
476                        switch (t) {
477                          case "scroll":
478                            e._calcDimensionsWithScroll(),
479                              e.observeScrollDir(),
480                              e.stickyPosition();
481                            break;
482                          case "resize":
483                          default:
484                            e._widthBreakpoint(),
485                              e.calcDimensions(),
486                              e.stickyPosition(!0);
487                        }
488                        e._running = !1;
489                      }));
490                  }
491                },
492                {
493                  key: "_setSupportFeatures",
494                  value: function() {
495                    var t = this.support;
496                    (t.transform = c.supportTransform()),
497                      (t.transform3d = c.supportTransform(!0));
498                  }
499                },
500                {
501                  key: "_getTranslate",
502                  value: function() {
503                    var t =
504                        0 < arguments.length && void 0 !== arguments[0]
505                          ? arguments[0]
506                          : 0,
507                      e =
508                        1 < arguments.length && void 0 !== arguments[1]
509                          ? arguments[1]
510                          : 0,
511                      i =
512                        2 < arguments.length && void 0 !== arguments[2]
513                          ? arguments[2]
514                          : 0;
515                    return this.support.transform3d
516                      ? "translate3d(" + t + ", " + e + ", " + i + ")"
517                      : !!this.support.translate &&
518                          "translate(" + t + ", " + e + ")";
519                  }
520                },
521                {
522                  key: "destroy",
523                  value: function() {
524                    window.removeEventListener("resize", this, { capture: !1 }),
525                      window.removeEventListener("scroll", this, {
526                        capture: !1
527                      }),
528                      this.sidebar.classList.remove(this.options.stickyClass),
529                      (this.sidebar.style.minHeight = ""),
530                      this.sidebar.removeEventListener("update" + l, this);
531                    var t = { inner: {}, outer: {} };
532                    for (var e in ((t.inner = {
533                      position: "",
534                      top: "",
535                      left: "",
536                      bottom: "",
537                      width: "",
538                      transform: ""
539                    }),
540                    (t.outer = { height: "", position: "" }),
541                    t.outer))
542                      this.sidebar.style[e] = t.outer[e];
543                    for (var i in t.inner)
544                      this.sidebarInner.style[i] = t.inner[i];
545                    this.options.resizeSensor &&
546                      "undefined" != typeof ResizeSensor &&
547                      (ResizeSensor.detach(this.sidebarInner, this.handleEvent),
548                      ResizeSensor.detach(this.container, this.handleEvent));
549                  }
550                }
551              ],
552              [
553                {
554                  key: "supportTransform",
555                  value: function(t) {
556                    var i = !1,
557                      e = t ? "perspective" : "transform",
558                      n = e.charAt(0).toUpperCase() + e.slice(1),
559                      o = document.createElement("support").style;
560                    return (
561                      (e + " " + ["Webkit", "Moz", "O", "ms"].join(n + " ") + n)
562                        .split(" ")
563                        .forEach(function(t, e) {
564                          if (void 0 !== o[t]) return (i = t), !1;
565                        }),
566                      i
567                    );
568                  }
569                },
570                {
571                  key: "eventTrigger",
572                  value: function(t, e, i) {
573                    try {
574                      var n = new CustomEvent(e, { detail: i });
575                    } catch (t) {
576                      (n = document.createEvent("CustomEvent")).initCustomEvent(
577                        e,
578                        !0,
579                        !0,
580                        i
581                      );
582                    }
583                    t.dispatchEvent(n);
584                  }
585                },
586                {
587                  key: "extend",
588                  value: function(t, e) {
589                    var i = {};
590                    for (var n in t)
591                      void 0 !== e[n] ? (i[n] = e[n]) : (i[n] = t[n]);
592                    return i;
593                  }
594                },
595                {
596                  key: "offsetRelative",
597                  value: function(t) {
598                    var e = { left: 0, top: 0 };
599                    do {
600                      var i = t.offsetTop,
601                        n = t.offsetLeft;
602                      isNaN(i) || (e.top += i),
603                        isNaN(n) || (e.left += n),
604                        (t =
605                          "BODY" === t.tagName
606                            ? t.parentElement
607                            : t.offsetParent);
608                    } while (t);
609                    return e;
610                  }
611                },
612                {
613                  key: "addClass",
614                  value: function(t, e) {
615                    c.hasClass(t, e) ||
616                      (t.classList
617                        ? t.classList.add(e)
618                        : (t.className += " " + e));
619                  }
620                },
621                {
622                  key: "removeClass",
623                  value: function(t, e) {
624                    c.hasClass(t, e) &&
625                      (t.classList
626                        ? t.classList.remove(e)
627                        : (t.className = t.className.replace(
628                            new RegExp(
629                              "(^|\\b)" + e.split(" ").join("|") + "(\\b|$)",
630                              "gi"
631                            ),
632                            " "
633                          )));
634                  }
635                },
636                {
637                  key: "hasClass",
638                  value: function(t, e) {
639                    return t.classList
640                      ? t.classList.contains(e)
641                      : new RegExp("(^| )" + e + "( |$)", "gi").test(
642                          t.className
643                        );
644                  }
645                },
646                {
647                  key: "defaults",
648                  get: function() {
649                    return n;
650                  }
651                }
652              ]
653            ),
654            c
655          );
656        })());
657      (t.default = i), (window.StickySidebar = i);
658    })(e);
659  });
660  return (
661    t(i),
662    t(
663      e(function(t, e) {
664        (function(t) {
665          var e,
666            s = (e = t) && e.__esModule ? e : { default: e };
667          !(function() {
668            if ("undefined" != typeof window) {
669              var n = window.$ || window.jQuery || window.Zepto,
670                o = "stickySidebar";
671              if (n) {
672                (n.fn.stickySidebar = function(i) {
673                  return this.each(function() {
674                    var t = n(this),
675                      e = n(this).data(o);
676                    if (
677                      (e ||
678                        ((e = new s.default(this, "object" == typeof i && i)),
679                        t.data(o, e)),
680                      "string" == typeof i)
681                    ) {
682                      if (
683                        void 0 === e[i] &&
684                        -1 === ["destroy", "updateSticky"].indexOf(i)
685                      )
686                        throw new Error('No method named "' + i + '"');
687                      e[i]();
688                    }
689                  });
690                }),
691                  (n.fn.stickySidebar.Constructor = s.default);
692                var t = n.fn.stickySidebar;
693                n.fn.stickySidebar.noConflict = function() {
694                  return (n.fn.stickySidebar = t), this;
695                };
696              }
697            }
698          })();
699        })(i);
700      })
701    )
702  );
703});

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.