PageSourceSearch

https://sealaskaheritage.org/wp-content/themes/themebau/assets/vendors/js/jarallax-element.js?ver=1.0.1

js sealaskaheritage.org collected 2026-09-24 08:51:17 UTC 5,103 bytes, 147 lines download raw bytes

1/*!
2 * DEPRECATED Elements Extension for Jarallax. Use lax.js instead https://github.com/alexfoxy/lax.js
3 */
4
5(function (global, factory) {
6  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7  typeof define === 'function' && define.amd ? define(factory) :
8  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jarallaxElement = factory());
9})(this, (function () { 'use strict';
10
11  function ready(callback) {
12    if ('complete' === document.readyState || 'interactive' === document.readyState) {
13      // Already ready or interactive, execute callback
14      callback();
15    } else {
16      document.addEventListener('DOMContentLoaded', callback, {
17        capture: true,
18        once: true,
19        passive: true
20      });
21    }
22  }
23
24  /* eslint-disable import/no-mutable-exports */
25
26  /* eslint-disable no-restricted-globals */
27  let win;
28
29  if ('undefined' !== typeof window) {
30    win = window;
31  } else if ('undefined' !== typeof global) {
32    win = global;
33  } else if ('undefined' !== typeof self) {
34    win = self;
35  } else {
36    win = {};
37  }
38
39  var global$1 = win;
40
41  function jarallaxElement(jarallax = global$1.jarallax) {
42    // eslint-disable-next-line no-console
43    console.warn("Jarallax Element extension is DEPRECATED, please, avoid using it. We recommend you look at something like `lax.js` library <https://github.com/alexfoxy/lax.js>. It is much more powerful and has a less code (in cases when you don't want to add parallax backgrounds).");
44
45    if ('undefined' === typeof jarallax) {
46      return;
47    }
48
49    const Jarallax = jarallax.constructor; // redefine default methods
50
51    ['initImg', 'canInitParallax', 'init', 'destroy', 'coverImage', 'isVisible', 'onScroll', 'onResize'].forEach(key => {
52      const def = Jarallax.prototype[key];
53
54      Jarallax.prototype[key] = function (...args) {
55        const self = this;
56
57        if ('initImg' === key && null !== self.$item.getAttribute('data-jarallax-element')) {
58          self.options.type = 'element';
59          self.pureOptions.speed = self.$item.getAttribute('data-jarallax-element') || '100';
60        }
61
62        if ('element' !== self.options.type) {
63          return def.apply(self, args);
64        }
65
66        self.pureOptions.threshold = self.$item.getAttribute('data-threshold') || '';
67
68        switch (key) {
69          case 'init':
70            {
71              const speedArr = `${self.pureOptions.speed}`.split(' ');
72              self.options.speed = self.pureOptions.speed || 0;
73              self.options.speedY = speedArr[0] ? parseFloat(speedArr[0]) : 0;
74              self.options.speedX = speedArr[1] ? parseFloat(speedArr[1]) : 0;
75              const thresholdArr = self.pureOptions.threshold.split(' ');
76              self.options.thresholdY = thresholdArr[0] ? parseFloat(thresholdArr[0]) : null;
77              self.options.thresholdX = thresholdArr[1] ? parseFloat(thresholdArr[1]) : null;
78              def.apply(self, args); // restore background image if available.
79
80              const originalStylesTag = self.$item.getAttribute('data-jarallax-original-styles');
81
82              if (originalStylesTag) {
83                self.$item.setAttribute('style', originalStylesTag);
84              }
85
86              return true;
87            }
88
89          case 'onResize':
90            {
91              const defTransform = self.css(self.$item, 'transform');
92              self.css(self.$item, {
93                transform: ''
94              });
95              const rect = self.$item.getBoundingClientRect();
96              self.itemData = {
97                width: rect.width,
98                height: rect.height,
99                y: rect.top + self.getWindowData().y,
100                x: rect.left
101              };
102              self.css(self.$item, {
103                transform: defTransform
104              });
105              break;
106            }
107
108          case 'onScroll':
109            {
110              const wnd = self.getWindowData();
111              const centerPercent = (wnd.y + wnd.height / 2 - self.itemData.y - self.itemData.height / 2) / (wnd.height / 2);
112              const moveY = centerPercent * self.options.speedY;
113              const moveX = centerPercent * self.options.speedX;
114              let my = moveY;
115              let mx = moveX;
116              if (null !== self.options.thresholdY && moveY > self.options.thresholdY) my = 0;
117              if (null !== self.options.thresholdX && moveX > self.options.thresholdX) mx = 0;
118              self.css(self.$item, {
119                transform: `translate3d(${mx}px,${my}px,0)`
120              });
121              break;
122            }
123
124          case 'initImg':
125          case 'isVisible':
126          case 'coverImage':
127            return true;
128          // no default
129        }
130
131        return def.apply(self, args);
132      };
133    });
134  }
135
136  jarallaxElement(); // data-jarallax-element initialization
137
138  ready(() => {
139    if ('undefined' !== typeof global$1.jarallax) {
140      global$1.jarallax(document.querySelectorAll('[data-jarallax-element]'));
141    }
142  });
143
144  return jarallaxElement;
145
146}));
147

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.