PageSourceSearch

https://www.rumahenergi.org/wp-content/themes/rumahenergi/assets/j…/parallax-background.min.js?ver=6.8.6

js rumahenergi.org collected 2026-09-25 04:53:52 UTC 8,173 bytes, 246 lines download raw bytes

1/**
2 * Parallax Background version 1.1
3 * https://github.com/erensuleymanoglu/parallax-background
4 * by Eren Suleymanoglu
5 */
6(function ($) {
7	
8	'use strict';
9	
10	/**
11	 * Polyfill for requestAnimationFrame
12	 * via https://gist.github.com/paulirish/1579671
13	 */
14	(function () {
15		var lastTime = 0;
16		var vendors  = ['ms', 'moz', 'webkit', 'o'];
17		
18		for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
19			window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
20			window.cancelAnimationFrame  = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
21		}
22		
23		if (!window.requestAnimationFrame) {
24			window.requestAnimationFrame = function (callback) {
25				var currTime   = new Date().getTime();
26				var timeToCall = Math.max(0, 16 - (currTime - lastTime));
27				var id         = window.setTimeout(function () {
28					callback(currTime + timeToCall);
29				}, timeToCall);
30				lastTime       = currTime + timeToCall;
31				return id;
32			};
33		}
34		
35		if (!window.cancelAnimationFrame) {
36			window.cancelAnimationFrame = function (id) {
37				clearTimeout(id);
38			};
39		}
40	}());
41	
42	function isMobile() {
43		if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
44			|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
44substr(0, 4))) {
45			return true;
46		} else {
47			return false;
48		}
49	}
50	
51	/**
52	 * Viewport checker
53	 * via https://github.com/moagrius/isOnScreen
54	 *
55	 * @returns {boolean}
56	 */
57	$.fn.isOnScreen = function () {
58		var win = $(window);
59		
60		var viewport    = {
61			top  : win.scrollTop(),
62			left : win.scrollLeft()
63		};
64		viewport.right  = viewport.left + win.width();
65		viewport.bottom = viewport.top + win.height();
66		
67		var bounds    = this.offset();
68		bounds.right  = bounds.left + this.outerWidth();
69		bounds.bottom = bounds.top + this.outerHeight();
70		
71		return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
72	};
73	
74	$.fn.parallaxBackground = function (options) {
75		return this.each(function () {
76			var a = $(this);
77			var b = $(window);
78			var c, d, e, f, h, p, s, t, w;
79			var pt, pb, pl, pr, hd, wd;
80			var x = 0, y = 0, z = 0, g, i = 0;
81			
82			var defaults = {
83				parallaxBgImage    : '',
84				parallaxBgPosition : 'center center',
85				parallaxBgRepeat   : 'no-repeat',
86				parallaxBgSize     : 'cover',
87				parallaxSpeed      : 9,
88				parallaxDirection  : 'up'
89			};
90			
91			var data = a.data();
92			
93			var settings = $.extend({}, defaults, options, data);
94			
95			if (settings.parallaxSpeed > 1) {
96				settings.parallaxSpeed = 1;
97			} else if (settings.parallaxSpeed < 0) {
98				settings.parallaxSpeed = 0;
99			}
100			
101			if (a.find('.parallax-inner').length < 1) {
102				a.prepend('<div class="parallax-inner"></div>');
103			}
104			
105			c = a.find('.parallax-inner');
106			
107			function resizeBackground(a) {
108				w = a.outerWidth();
109				h = a.outerHeight();
110				
111				if (isMobile()) {
112					f = 2;
113				} else {
114					f = 1.7;
115				}
116				
117				if (settings.parallaxDirection === 'left' || settings.parallaxDirection === 'right') {
118					w += ((w * Math.abs(parseFloat(settings.parallaxSpeed))) * f);
119				}
120				
121				if (settings.parallaxDirection === 'up' || settings.parallaxDirection === 'down') {
122					h += ((h * Math.abs(parseFloat(settings.parallaxSpeed))) * f);
123				}
124				
125				return [w, h];
126			}
127			
128			function repositionBackground(a, d) {
129				pl = parseInt(a.css('padding-left').replace('px', ''));
130				pr = parseInt(a.css('padding-right').replace('px', ''));
131				pt = parseInt(a.css('padding-top').replace('px', ''));
132				pb = parseInt(a.css('padding-bottom').replace('px', ''));
133				
134				hd = (d[1] - a.outerHeight()) / 2;
135				wd = (d[0] - a.outerWidth()) / 2;
136				
137				switch (settings.parallaxDirection) {
138					case 'up':
139						x = -pl;
140						y = -(hd + pt);
141						z = 0;
142						break;
143					case 'down':
144						x = -pl;
145						y = -(hd + pt);
146						z = 0;
147						break;
148					case 'left':
149						x = -(wd + pl);
150						y = -pt;
151						z = 0;
152						break;
153					case 'right':
154						x = -(wd + pl);
155						y = -pt;
156						z = 0;
157						break;
158				}
159				
160				return [x, y, z];
161			}
162			
163			d = resizeBackground(a);
164			e = repositionBackground(a, d);
165			
166			a.css({
167				'position'   : 'relative',
168				'background' : 'transparent',
169				'overflow'   : 'hidden',
170				'z-index'    : '1'
171			});
172			
173			c.css({
174				'position'            : 'absolute',
175				'background-image'    : 'url(' + settings.parallaxBgImage + ')',
176				'background-position' : settings.parallaxBgPosition,
177				'background-repeat'   : settings.parallaxBgRepeat,
178				'background-size'     : settings.parallaxBgSize,
179				'width'               : d[0],
180				'height'              : d[1],
181				'transform'           : 'translate3d(' + e[0] + 'px, ' + e[1] + 'px, ' + e[2] + 'px)',
182				'z-index'             : '-1'
183			});
184			
185			b.resize(function () {
186				d = resizeBackground(a);
187				e = repositionBackground(a, d);
188				
189				c.css({
190					'width'     : d[0],
191					'height'    : d[1],
192					'transform' : 'translate3d(' + e[0] + 'px, ' + e[1] + 'px, ' + e[2] + 'px)'
193				});
194			});
195			
196			if (settings.parallaxDirection === 'left' || settings.parallaxDirection === 'right') {
197				p = 0;
198				s = e[0];
199			}
200			
201			if (settings.parallaxDirection === 'up' || settings.parallaxDirection === 'down') {
202				p = 0;
203				s = e[1];
204			}
205			
206			if (a.isOnScreen()) {
207				g = b.scrollTop();
208			}
209			
210			b.on('scroll', function () {
211				i = b.scrollTop() - g;
212				g = b.scrollTop();
213				
214				p = i * (parseFloat(settings.parallaxSpeed) / 4);
215				
216				if (a.isOnScreen()) {
217					if (settings.parallaxDirection === 'up') {
218						s += -p;
219						t = 'translate3d(' + e[0] + 'px, ' + s + 'px, ' + e[2] + 'px)';
220					}
221					
222					if (settings.parallaxDirection === 'down') {
223						s += p;
224						t = 'translate3d(' + e[0] + 'px, ' + s + 'px, ' + e[2] + 'px)';
225					}
226					
227					if (settings.parallaxDirection === 'left') {
228						s += p;
229						t = 'translate3d(' + s + 'px, ' + e[1] + 'px, ' + e[2] + 'px)';
230					}
231					
232					if (settings.parallaxDirection === 'right') {
233						s += -p;
234						t = 'translate3d(' + s + 'px, ' + e[1] + 'px, ' + e[2] + 'px)';
235					}
236					
237					c.css({
238						'width'     : d[0],
239						'height'    : d[1],
240						'transform' : t
241					});
242				}
243			});
244		});
245	}
246})(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.