PageSourceSearch

https://ringbot.io/wp-content/themes/saspik/assets/js/jquery.parallax-scroll.js?ver=1.0.0

js ringbot.io collected 2026-10-06 05:22:52 UTC 7,870 bytes, 210 lines download raw bytes

1jQuery(document).ready(function ($) {
2  var ParallaxScroll = {
3    /* PUBLIC VARIABLES */
4    showLogs: false,
5    round: 1000,
6
7    /* PUBLIC FUNCTIONS */
8    init: function init() {
9      this._log("init");
10
11      if (this._inited) {
12        this._log("Already Inited");
13
14        this._inited = true;
15        return;
16      }
17
18      this._requestAnimationFrame = function () {
19        return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (
20        /* function */
21        callback,
22        /* DOMElement */
23        element) {
24          window.setTimeout(callback, 1000 / 60);
25        };
26      }();
27
28      this._onScroll(true);
29    },
30
31    /* PRIVATE VARIABLES */
32    _inited: false,
33    _properties: ['x', 'y', 'z', 'rotateX', 'rotateY', 'rotateZ', 'scaleX', 'scaleY', 'scaleZ', 'scale'],
34    _requestAnimationFrame: null,
35
36    /* PRIVATE FUNCTIONS */
37    _log: function _log(message) {
38      if (this.showLogs) console.log("Parallax Scroll / " + message);
39    },
40    _onScroll: function _onScroll(noSmooth) {
41      var scroll = $(document).scrollTop();
42      var windowHeight = $(window).height();
43
44      this._log("onScroll " + scroll);
45
46      $("[data-parallax]").each($.proxy(function (index, el) {
47        var $el = $(el);
48        var properties = [];
49        var applyProperties = false;
50        var style = $el.data("style");
51
52        if (style == undefined) {
53          style = $el.attr("style") || "";
54          $el.data("style", style);
55        }
56
57        var datas = [$el.data("parallax")];
58        var iData;
59
60        for (iData = 2;; iData++) {
61          if ($el.data("parallax" + iData)) {
62            datas.push($el.data("parallax-" + iData));
63          } else {
64            break;
65          }
66        }
67
68        var datasLength = datas.length;
69
70        for (iData = 0; iData < datasLength; iData++) {
71          var data = datas[iData];
72          var scrollFrom = data["from-scroll"];
73          if (scrollFrom == undefined) scrollFrom = Math.max(0, $(el).offset().top - windowHeight);
74          scrollFrom = scrollFrom | 0;
75          var scrollDistance = data["distance"];
76          var scrollTo = data["to-scroll"];
77          if (scrollDistance == undefined && scrollTo == undefined) scrollDistance = windowHeight;
78          scrollDistance = Math.max(scrollDistance | 0, 1);
79          var easing = data["easing"];
80          var easingReturn = data["easing-return"];
81          if (easing == undefined || !$.easing || !$.easing[easing]) easing = null;
82          if (easingReturn == undefined || !$.easing || !$.easing[easingReturn]) easingReturn = easing;
83
84          if (easing) {
85            var totalTime = data["duration"];
86            if (totalTime == undefined) totalTime = scrollDistance;
87            totalTime = Math.max(totalTime | 0, 1);
88            var totalTimeReturn = data["duration-return"];
89            if (totalTimeReturn == undefined) totalTimeReturn = totalTime;
90            scrollDistance = 1;
91            var currentTime = $el.data("current-time");
92            if (currentTime == undefined) currentTime = 0;
93          }
94
95          if (scrollTo == undefined) scrollTo = scrollFrom + scrollDistance;
96          scrollTo = scrollTo | 0;
97          var smoothness = data["smoothness"];
98          if (smoothness == undefined) smoothness = 30;
99          smoothness = smoothness | 0;
100          if (noSmooth || smoothness == 0) smoothness = 1;
101          smoothness = smoothness | 0;
102          var scrollCurrent = scroll;
103          scrollCurrent = Math.max(scrollCurrent, scrollFrom);
104          scrollCurrent = Math.min(scrollCurrent, scrollTo);
105
106          if (easing) {
107            if ($el.data("sens") == undefined) $el.data("sens", "back");
108
109            if (scrollCurrent > scrollFrom) {
110              if ($el.data("sens") == "back") {
111                currentTime = 1;
112                $el.data("sens", "go");
113              } else {
114                currentTime++;
115              }
116            }
117
118            if (scrollCurrent < scrollTo) {
119              if ($el.data("sens") == "go") {
120                currentTime = 1;
121                $el.data("sens", "back");
122              } else {
123                currentTime++;
124              }
125            }
126
127            if (noSmooth) currentTime = totalTime;
128            $el.data("current-time", currentTime);
129          }
130
131          this._properties.map($.proxy(function (prop) {
132            var defaultProp = 0;
133            var to = data[prop];
134            if (to == undefined) return;
135
136            if (prop == "scale" || prop == "scaleX" || prop == "scaleY" || prop == "scaleZ") {
137              defaultProp = 1;
138            } else {
139              to = to | 0;
140            }
141
142            var prev = $el.data("_" + prop);
143            if (prev == undefined) prev = defaultProp;
144            var next = (to - defaultProp) * ((scrollCurrent - scrollFrom) / (scrollTo - scrollFrom)) + defaultProp;
145            var val = prev + (next - prev) / smoothness;
146
147            if (easing && currentTime > 0 && currentTime <= totalTime) {
148              var from = defaultProp;
149
150              if ($el.data("sens") == "back") {
151                from = to;
152                to = -to;
153                easing = easingReturn;
154                totalTime = totalTimeReturn;
155              }
156
157              val = $.easing[easing](null, currentTime, from, to, totalTime);
158            }
159
160            val = Math.ceil(val * this.round) / this.round;
161            if (val == prev && next == to) val = to;
162            if (!properties[prop]) properties[prop] = 0;
163            properties[prop] += val;
164
165            if (prev != properties[prop]) {
166              $el.data("_" + prop, properties[prop]);
167              applyProperties = true;
168            }
169          }, this));
170        }
171
172        if (applyProperties) {
173          if (properties["z"] != undefined) {
174            var perspective = data["perspective"];
175            if (perspective == undefined) perspective = 800;
176            var $parent = $el.parent();
177            if (!$parent.data("style")) $parent.data("style", $parent.attr("style") || "");
178            $parent.attr("style", "perspective:" + perspective + "px; -webkit-perspective:" + perspective + "px; " + $parent.data("style"));
179          }
180
181          if (properties["scaleX"] == undefined) properties["scaleX"] = 1;
182          if (properties["scaleY"] == undefined) properties["scaleY"] = 1;
183          if (properties["scaleZ"] == undefined) properties["scaleZ"] = 1;
184
185          if (properties["scale"] != undefined) {
186            properties["scaleX"] *= properties["scale"];
187            properties["scaleY"] *= properties["scale"];
188            properties["scaleZ"] *= properties["scale"];
189          }
190
191          var translate3d = "translate3d(" + (properties["x"] ? properties["x"] : 0) + "px, " + (properties["y"] ? properties["y"] : 0) + "px, " + (properties["z"] ? properties["z"] : 0) + "px)";
192          var rotate3d = "rotateX(" + (properties["rotateX"] ? properties["rotateX"] : 0) + "deg) rotateY(" + (properties["rotateY"] ? properties["rotateY"] : 0) + "deg) rotateZ(" + (properties["rotateZ"] ? properties["rotateZ"] : 0) + "deg)";
193          var scale3d = "scaleX(" + properties["scaleX"] + ") scaleY(" + properties["scaleY"] + ") scaleZ(" + properties["scaleZ"] + ")";
194          var cssTransform = translate3d + " " + rotate3d + " " + scale3d + ";";
195
196          this._log(cssTransform);
197
198          $el.attr("style", "transform:" + cssTransform + " -webkit-transform:" + cssTransform + " " + style);
199        }
200      }, this));
201
202      if (window.requestAnimationFrame) {
203        window.requestAnimationFrame($.proxy(this._onScroll, this, false));
204      } else {
205        this._requestAnimationFrame($.proxy(this._onScroll, this, false));
206      }
207    }
208  };
209  ParallaxScroll.init();
210});

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.