PageSourceSearch

https://www.skipark-filipovice.cz/assets/anim.js?v=02

js skipark-filipovice.cz collected 2026-10-07 11:15:16 UTC 5,452 bytes, 205 lines download raw bytes

1window.rsharpe = window.rsharpe || {};
2
3(function ($, ns) {
4  'use strict';
5
6  var plugin = ns.waypoint = {
7    $scrollElement: $(window),
8    callbacksList: [],
9
10    defaults: {
11      lockTime: 250
12    },
13
14    init: function (config) {
15      var callbacks = this.data('callbacks.waypoint') || $.Callbacks();
16
17      config.offset = config.offset || 0;
18      config._order = ++callbacks.count || (callbacks.count = 1);
19
20      !plugin.callbacksList.includes(callbacks) && plugin.callbacksList.push(callbacks);
21      callbacks.add(config._callee = plugin._onScroll.bind(this, config, []));
22
23      return plugin._start.call(
24        this.data('callbacks.waypoint', callbacks), plugin.defaults.lockTime
25      );
26    },
27
28    _onScroll: function (config, trashWPs, sPos) {
29      plugin._observe.call(this, config, trashWPs, sPos, function () {
30        // count лучше не декрементировать, 
31        // т.к. к этой цифре привязаны данные waypoint'ов; 
32        // в таком случае придется удалять и их также
33        this.data('callbacks.waypoint')
34          .remove(config._callee);
35      });
36    },
37
38    _observe: function (config, trashWPs, sPos, fallback) {
39      if (trashWPs.length === this.length) {
40        fallback && fallback.call(this);
41        return;
42      }
43
44      this
45        .filter(function () {
46          return trashWPs.indexOf(this) === -1;
47        })
48        .each(function () {
49          var $waypoint = $(this).data('waypoint', config);
50
51          if (!$waypoint.is(':visible')) {
52            return;
53          }
54
55          var wPos = new WaypointPos($waypoint);
56          var wOffset = wPos.height * config.offset / 100;
57
58          // HACK: Дополнительная единица нужна чтобы исключить проверки на равенство (<=, >=), 
59          // т.к. позиции некоторых элементом могут быть с плавающей точкой.
60
61          if (sPos.bottom > wPos.top + wOffset && sPos.top + 1 < wPos.bottom) {
62            plugin._tryFireEnter.call($waypoint);
63
64            if (sPos.top + 1 > wPos.top) {
65              plugin._tryFireActive.call($waypoint);
66            } else {
67              plugin._tryFireInactive.call($waypoint);
68            }
69          } else {
70            plugin._tryFireInactive.call($waypoint);
71
72            if (plugin._tryFireExit.call($waypoint) && config.once) {
73              trashWPs.push($waypoint[0]);
74            }
75          }
76        });
77    },
78
79    _tryFireEnter: function () {
80      var key = 'isDetected.waypoint' + this.data('waypoint')._order;
81
82      if (this.data(key)) {
83        return false;
84      }
85
86      plugin._fire.call(this.data(key, true), 'onEnter');
87      return true;
88    },
89
90    _tryFireExit: function () {
91      var key = 'isDetected.waypoint' + this.data('waypoint')._order;
92
93      if (!this.data(key)) {
94        return false;
95      }
96
97      plugin._fire.call(this.data(key, false), 'onExit');
98      return true;
99    },
100
101    _tryFireActive: function () {
102      var key = 'isActive.waypoint' + this.data('waypoint')._order;
103
104      if (this.data(key)) {
105        return false;
106      }
107
108      plugin._fire.call(this.data(key, true), 'onActive');
109      return true;
110    },
111
112    _tryFireInactive: function () {
113      var key = 'isActive.waypoint' + this.data('waypoint')._order;
114
115      if (!this.data(key)) {
116        return false;
117      }
118
119      plugin._fire.call(this.data(key, false), 'onInactive');
120      return true;
121    },
122
123    _fire: function (fnName) {
124      var callback = this.data('waypoint')[fnName];
125      callback && callback.call(this);
126    },
127
128    _start: function (lockTime) {
129      if (!plugin.isInit) {
130        plugin.$scrollElement.on('scroll resize', function () {
131          if (!plugin.locked) {
132            plugin.locked = true;
133
134            setTimeout(function () {
135              plugin.callbacksList.forEach(function (item) {
136                item.fire(new ScrollPos(plugin.$scrollElement));
137              });
138
139              plugin.locked = false;
140            }, lockTime);
141          }
142        });
143
144        plugin.isInit = true;
145      }
146
147      plugin.$scrollElement.trigger('resize');
148      return this;
149    },
150  };
151
152  //======================
153
154  var PositionBase = function () {
155    this.bottom = this.top + this.height;
156  };
157
158  //======================
159
160  var ScrollPos = function ($element) {
161    this.top = $element.scrollTop();
162    this.height = $element.height();
163    PositionBase.call(this);
164  };
165
166  ScrollPos.prototype = Object.create(PositionBase.prototype);
167  ScrollPos.prototype.constructor = ScrollPos;
168
169  //======================
170
171  var WaypointPos = function ($element) {
172    this.top = $element.offset().top;
173    this.height = $element.outerHeight();
174    PositionBase.call(this);
175  };
176
177  WaypointPos.prototype = Object.create(PositionBase.prototype);
178  WaypointPos.prototype.constructor = WaypointPos;
179
180  //======================
181
182  $.fn.waypoint = function (config) {
183    if (!this.length) {
184      return this;
185    }
186
187    return plugin.init.call(this, config || {});
188  };
189
190})(jQuery, rsharpe);
191
192$(document).ready(function () {
193  $('.intro-text').waypoint({
194    offset: 10,
195    onEnter: function () {
196      $(this).addClass("intro-text--animed");
197    },
198  });
199  $('.title-anim').waypoint({
200    offset: 10,
201    onEnter: function () {
202      $(this).addClass("title-animed");
203    },
204  });
205});

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.