PageSourceSearch

https://obrixlabs.com/wp-content/themes/aimo/assets/js/libs/parallax-background.js?ver=1.0.1

js obrixlabs.com collected 2026-10-07 00:31:07 UTC 16,967 bytes, 426 lines download raw bytes

vendor: 4,106 bytes, lines 1-100
1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// define getter function for harmony exports
37/******/ 	__webpack_require__.d = function(exports, name, getter) {
38/******/ 		if(!__webpack_require__.o(exports, name)) {
39/******/ 			Object.defineProperty(exports, name, {
40/******/ 				configurable: false,
41/******/ 				enumerable: true,
42/******/ 				get: getter
43/******/ 			});
44/******/ 		}
45/******/ 	};
46/******/
47/******/ 	// getDefaultExport function for compatibility with non-harmony modules
48/******/ 	__webpack_require__.n = function(module) {
49/******/ 		var getter = module && module.__esModule ?
50/******/ 			function getDefault() { return module['default']; } :
51/******/ 			function getModuleExports() { return module; };
52/******/ 		__webpack_require__.d(getter, 'a', getter);
53/******/ 		return getter;
54/******/ 	};
55/******/
56/******/ 	// Object.prototype.hasOwnProperty.call
57/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58/******/
59/******/ 	// __webpack_public_path__
60/******/ 	__webpack_require__.p = "";
61/******/
62/******/ 	// Load entry module and return exports
63/******/ 	return __webpack_require__(__webpack_require__.s = 0);
64/******/ })
65/************************************************************************/
66/******/ ([
67/* 0 */
68/***/ (function(module, exports, __webpack_require__) {
69
70"use strict";
71/*
72 Version: 1.0.8
73 Author: lemehovskiy
74 Website: https://lemehovskiy.github.io/parallax-background
75 Repo: https://github.com/lemehovskiy/parallax_background
76 */
77
78
79
80var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
81
82var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
83
84function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
85
86(function ($) {
87    var ParallaxBackground = function () {
88        function ParallaxBackground(element, options) {
89            _classCallCheck(this, ParallaxBackground);
90
91            var self = this;
92
93            //extend by function call
94            self.settings = $.extend(true, {
95
96                event: 'scroll',
97                animation_type: 'shift',
98                zoom: 20,
99                rotate_perspective: 1400,
100                animate_duration: 1,
101                ignore_z_index: false,
102                gyroscope_event: true
103
104            }, options);
105
106            self.$element = $(element);
107            self.$element_inner = self.$element.find('.parallax-inner');
108
109            //extend by data options
110            self.data_options = self.$element.data('parallax-background');
111            self.settings = $.extend(true, self.settings, self.data_options);
112
113            self.inner_size = self.settings.zoom + 100;
114            self.coef = self.inner_size / 100;
115            self.shift = self.settings.zoom / 2 / self.coef;
116
117            self.device_orientation = '';
118            self.viewport_top = 0;
119            self.viewport_bottom = 0;
120
121            self.init();
122        }
123
124        _createClass(ParallaxBackground, [{
125            key: 'init',
126            value: function init() {
127
128                if (typeof TweenLite === 'undefined') {
129                    console.warn('TweenMax or TweenLite library is required... https://greensock.com/tweenlite');
130                    return;
131                }
132
133                if (typeof CSSPlugin === 'undefined') {
134                    console.warn('CSSPlugin in required... https://greensock.com/CSSPlugin');
135                    return;
136                }
137
138                var self = this;
139
140                self.set_elements_styles();
141
142                self.update_window_size();
143                self.update_orientation();
144
145                $(window).on('resize', function () {
146                    self.update_window_size();
147                    self.update_orientation();
148                });
149
150                if (self.settings.event == 'scroll') {
151                    self.update_viewports();
152
153                    $(window).on('scroll', function () {
154                        self.update_viewports();
155                    });
156                }
157
158                if (self.settings.event == 'scroll') {
159                    self.subscribe_scroll_event();
160                } else if (self.settings.event == 'mouse_move') {
161                    self.subscribe_mouse_move_event();
162                }
163
164                if (self.settings.gyroscope_event) {
165                    self.subscribe_gyro_event();
166                }
167            }
168        }, {
169            key: 'update_window_size',
170            value: function update_window_size() {
171                var self = this;
172
173                self.ww = window.innerWidth;
174                self.wh = window.innerHeight;
175            }
176        }, {
177            key: 'update_viewports',
178            value: function update_viewports() {
179                var self = this;
180
181                self.viewport_top = $(window).scrollTop();
182                self.viewport_bottom = self.viewport_top + self.wh;
183            }
184        }, {
185            key: 'set_elements_styles',
186            value: function set_elements_styles() {
187                var self = this;
188
189                self.$element.css({
190                    'overflow': 'hidden'
191                });
192
193                self.$element_inner.css({
194                    'top': -self.settings.zoom / 2 + '%',
195                    'left': -self.settings.zoom / 2 + '%',
196                    'height': self.inner_size + '%',
197                    'width': self.inner_size + '%',
198                    'position': 'absolute'
199
200                });
201
202                if (self.settings.animation_type == 'rotate') {
203                    TweenLite.set(self.$element, { perspective: self.settings.rotate_perspective });
204                    TweenLite.set(self.$element_inner, { transformStyle: "preserve-3d" });
205                }
206            }
207        }, {
208            key: 'update_orientation',
209            value: function update_orientation() {
210                var self = this;
211
212                if (self.ww > self.wh) {
213                    self.device_orientation = 'landscape';
214                } else {
215                    self.device_orientation = 'portrait';
216                }
217            }
218        }, {
219            key: 'subscribe_gyro_event',
220            value: function subscribe_gyro_event() {
221
222                var self = this;
223
224                var lastGamma = 0,
225                    lastBeta = 0,
226                    rangeGamma = 0,
227                    rangeBeta = 0;
228
229                window.addEventListener("deviceorientation", function (e) {
230
231                    var roundedGamma = Math.round(e.gamma),
232                        roundedBeta = Math.round(e.beta),
233                        x = 0,
234                        y = 0;
235
236                    if (roundedGamma > lastGamma && rangeGamma < 15) {
237                        rangeGamma++;
238                    } else if (roundedGamma < lastGamma && rangeGamma > -15) {
239                        rangeGamma--;
240                    }
241
242                    if (roundedBeta > lastBeta && rangeBeta < 15) {
243                        rangeBeta++;
244                    } else if (roundedBeta < lastBeta && rangeBeta > -15) {
245                        rangeBeta--;
246                    }
247
248                    lastGamma = roundedGamma;
249                    lastBeta = roundedBeta;
250
251                    var gamaInPercent = 100 / 15 * rangeGamma,
252                        betaInPercent = 100 / 15 * rangeBeta;
253
254                    //TODO Organize orientation statement
255
256                    if (self.device_orientation == 'landscape') {
257                        x = self.shift / self.coef / 100 * betaInPercent;
258                        y = self.shift / self.coef / 100 * gamaInPercent;
259                    } else {
260                        x = self.shift / self.coef / 100 * gamaInPercent;
261                        y = self.shift / self.coef / 100 * betaInPercent * -1;
262                    }
263
264                    if (self.settings.animation_type == 'shift') {
265                        TweenLite.to(self.$element_inner, self.settings.animate_duration, { x: y + '%', y: x + '%' });
266                    } else if (self.settings.animation_type == 'rotate') {
267                        TweenLite.to(self.$element_inner, self.settings.animate_duration, {
268                            rotationX: -y + '%',
269                            rotationY: -x + '%'
270                        });
271                    }
272                }, true);
273            }
274        }, {
275            key: 'get_cursor_shift_by_element',
276            value: function get_cursor_shift_by_element($element, cursor_x, cursor_y) {
277                var self = this;
278
279                var offset = $element.offset(),
280                    sectionWidth = $element.outerWidth(),
281                    sectionHeight = $element.outerHeight(),
282                    pageX = cursor_x - offset.left - $element.width() * 0.5,
283                    pageY = cursor_y - offset.top - $element.height() * 0.5,
284                    cursorPercentPositionX = pageX / sectionWidth * 2,
285                    cursorPercentPositionY = pageY / sectionHeight * 2,
286                    x = self.shift * cursorPercentPositionX,
287                    y = self.shift * cursorPercentPositionY;
288
289                return { x: x, y: y };
290            }
291        }, {
292            key: 'is_cursor_on_element',
293            value: function is_cursor_on_element($element, cursor_x, cursor_y) {
294
295                var offset = $element.offset();
296                var top = offset.top;
297                var left = offset.left;
298                var right = left + $element.outerWidth();
299                var bottom = top + $element.outerHeight();
300
301                return cursor_x > left && cursor_x < right && cursor_y > top && cursor_y < bottom;
302            }
303        }, {
304            key: 'subscribe_mouse_move_event',
305            value: function subscribe_mouse_move_event() {
306
307                var self = this;
308
309                if (self.settings.ignore_z_index) {
310                    var is_cursor_on_element = false;
311                    $(document).on("mousemove", function (e) {  
312                        if (self.is_cursor_on_element(self.$element, e.pageX, e.pageY)) {
313                            var cursor_shift = self.get_cursor_shift_by_element(self.$element, e.pageX, e.pageY, true);
314                            animate_on_mousemove(cursor_shift.x, cursor_shift.y);
315                            is_cursor_on_element = true;
316                        } else {
317                            if (is_cursor_on_element) {
318                                animate_on_mouseleave();
319                                is_cursor_on_element = false;
320                            }
321                        }
322                    });
323                } else {
324                    self.$element.on("mousemove", function (e) { 
325                        var cursor_shift = self.get_cursor_shift_by_element(self.$element, e.pageX, e.pageY, true);
326                        animate_on_mousemove(cursor_shift.x, cursor_shift.y);
327                    });
328
329                    self.$element.mouseleave(function () {
330                        animate_on_mouseleave();
331                    });
332                }
333
334                function animate_on_mouseleave() {
335                    if (self.settings.animation_type == 'shift') {
336                        TweenLite.to(self.$element_inner, self.settings.animate_duration, { x: '0%', y: '0%' });
337                    } else if (self.settings.animation_type == 'rotate') {
338                        TweenLite.to(self.$element_inner, self.settings.animate_duration, { rotationX: 0, rotationY: 0 });
339                    }
340                }
341
342                function animate_on_mousemove(x, y) {
343                    if (self.settings.animation_type == 'shift') {
344                        TweenLite.to(self.$element_inner, self.settings.animate_duration, { x: x + '%', y: y + '%' });
345                    } else if (self.settings.animation_type == 'rotate') {  
346                        TweenLite.to(self.$element_inner, self.settings.animate_duration, {
347                            rotationX: y + '%',
348                            rotationY: -x + '%'
349                        });
350                    }
351                }
352            }
353        }, {
354            key: 'subscribe_scroll_event',
355            value: function subscribe_scroll_event() {
356
357                var self = this;
358
359                var section_offset_top = 0,
360                    section_offset_bottom = 0,
361                    animation_progress_px = 0,
362                    animation_progress_percent = 0,
363                    section_height = 0,
364                    animation_length = 0;
365
366                on_resize();
367                on_resize_scroll();
368
369                $(window).on('resize', function () {
370                    on_resize();
371                });
372
373                $(window).on('scroll resize', function () {
374                    on_resize_scroll();
375                });
376
377                function on_resize() {
378                    section_height = self.$element.outerHeight();
379
380                    section_offset_top = self.$element.offset().top;
381                    section_offset_bottom = section_offset_top + section_height;
382
383                    animation_length = section_height + self.wh;
384                }
385
386                function on_resize_scroll() {
387                    if (self.viewport_bottom > section_offset_top && self.viewport_top < section_offset_bottom) {
388
389                        self.$element.addClass('active');
390
391                        animation_progress_px = self.viewport_bottom - section_offset_top - animation_length / 2;
392
393                        animation_progress_percent = animation_progress_px / (animation_length / 2);
394
395                        if (self.settings.animation_type == 'shift') {
396                            TweenLite.to(self.$element_inner, self.settings.animate_duration, { y: self.shift * animation_progress_percent + '%' });
397                        } else if (self.settings.animation_type == 'rotate') {
398                            TweenLite.to(self.$element_inner, self.settings.animate_duration, { rotationX: self.shift * animation_progress_percent + '%' });
399                        }
400                    } else {
401                        self.$element.removeClass('active');
402                    }
403                }
404            }
405        }]);
406
407        return ParallaxBackground;
408    }();
409
410    $.fn.parallaxBackground = function () { 
411        var $this = this,
412            opt = arguments[0],
413            args = Array.prototype.slice.call(arguments, 1),
414            length = $this.length,
415            i = void 0,
416            ret = void 0;  
417        for (i = 0; i < length; i++) {
418            if ((typeof opt === 'undefined' ? 'undefined' : _typeof(opt)) == 'object' || typeof opt == 'undefined') $this[i].parallax_background = new ParallaxBackground($this[i], opt);else ret = $this[i].parallax_background[opt].apply($this[i].parallax_background, args);
419            if (typeof ret != 'undefined') return ret;
420        }
421        return $this;
422    };
423})(jQuery);
424
425/***/ })
426/******/ ]);

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.