PageSourceSearch

https://casuarinahotels.com.my/wp-content/themes/carmelina/element…/js/libs/parallax-scroll.js?ver=1.2.0

js casuarinahotels.com.my collected 2026-10-02 13:40:14 UTC 11,503 bytes, 204 lines download raw bytes

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

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.