PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-dev4
Elementor Website Builder – more than just a page builder v4.0.0-dev4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / js / interactions-shared-utils.js

interactions-shared-utils.js in Elementor Website Builder – more than just a page builder 4.0.0-dev4, at assets/js/interactions-shared-utils.js

258 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "../modules/interactions/assets/js/interactions-breakpoints.js":
5 /*!*********************************************************************!*\
6 !*** ../modules/interactions/assets/js/interactions-breakpoints.js ***!
7 \*********************************************************************/
8 /***/ ((__unused_webpack_module, exports) => {
9
10 "use strict";
11
12
13 Object.defineProperty(exports, "__esModule", ({
14 value: true
15 }));
16 exports.getActiveBreakpoint = getActiveBreakpoint;
17 exports.initBreakpoints = initBreakpoints;
18 var RESIZE_DEBOUNCE_TIMEOUT = 100;
19 var breakpoints = {
20 list: {},
21 active: {},
22 onChange: function onChange() {}
23 };
24 function getActiveBreakpoint() {
25 return breakpoints.active;
26 }
27 function matchBreakpoint(width) {
28 for (var label in breakpoints.list) {
29 var breakpoint = breakpoints.list[label];
30 if ('min' === breakpoint.direction && width >= breakpoint.value) {
31 return label;
32 }
33 if ('max' === breakpoint.direction && breakpoint.value >= width) {
34 return label;
35 }
36 }
37 return 'desktop';
38 }
39 function attachEventListeners() {
40 var timeout = null;
41 var onResize = function onResize() {
42 if (timeout) {
43 window.clearTimeout(timeout);
44 timeout = null;
45 }
46 timeout = window.setTimeout(function () {
47 var currentBreakpoint = matchBreakpoint(window.innerWidth);
48 if (currentBreakpoint === breakpoints.active) {
49 return;
50 }
51 breakpoints.active = currentBreakpoint;
52 if ('function' === typeof breakpoints.onChange) {
53 breakpoints.onChange(breakpoints.active);
54 }
55 }, RESIZE_DEBOUNCE_TIMEOUT);
56 };
57 window.addEventListener('resize', onResize);
58 }
59 function getBreakpointsList() {
60 var _ElementorInteraction;
61 return ((_ElementorInteraction = ElementorInteractionsConfig) === null || _ElementorInteraction === void 0 ? void 0 : _ElementorInteraction.breakpoints) || {};
62 }
63 function initBreakpoints() {
64 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
65 onChange = _ref.onChange;
66 breakpoints.list = getBreakpointsList();
67 breakpoints.active = matchBreakpoint(window.innerWidth);
68 if ('function' === typeof onChange) {
69 breakpoints.onChange = onChange;
70 }
71 attachEventListeners();
72 }
73
74 /***/ }),
75
76 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
77 /*!***********************************************************************!*\
78 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
79 \***********************************************************************/
80 /***/ ((module) => {
81
82 function _interopRequireDefault(e) {
83 return e && e.__esModule ? e : {
84 "default": e
85 };
86 }
87 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
88
89 /***/ }),
90
91 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
92 /*!********************************************************!*\
93 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
94 \********************************************************/
95 /***/ ((module) => {
96
97 function _typeof(o) {
98 "@babel/helpers - typeof";
99
100 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
101 return typeof o;
102 } : function (o) {
103 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
104 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
105 }
106 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
107
108 /***/ })
109
110 /******/ });
111 /************************************************************************/
112 /******/ // The module cache
113 /******/ var __webpack_module_cache__ = {};
114 /******/
115 /******/ // The require function
116 /******/ function __webpack_require__(moduleId) {
117 /******/ // Check if module is in cache
118 /******/ var cachedModule = __webpack_module_cache__[moduleId];
119 /******/ if (cachedModule !== undefined) {
120 /******/ return cachedModule.exports;
121 /******/ }
122 /******/ // Create a new module (and put it into the cache)
123 /******/ var module = __webpack_module_cache__[moduleId] = {
124 /******/ // no module.id needed
125 /******/ // no module.loaded needed
126 /******/ exports: {}
127 /******/ };
128 /******/
129 /******/ // Execute the module function
130 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
131 /******/
132 /******/ // Return the exports of the module
133 /******/ return module.exports;
134 /******/ }
135 /******/
136 /************************************************************************/
137 var __webpack_exports__ = {};
138 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
139 (() => {
140 "use strict";
141 var exports = __webpack_exports__;
142 /*!**********************************************************************!*\
143 !*** ../modules/interactions/assets/js/interactions-shared-utils.js ***!
144 \**********************************************************************/
145
146
147 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
148 Object.defineProperty(exports, "__esModule", ({
149 value: true
150 }));
151 exports.config = config;
152 exports.extractInteractionId = extractInteractionId;
153 exports.getAnimateFunction = getAnimateFunction;
154 exports.getInViewFunction = getInViewFunction;
155 exports.parseInteractionsData = parseInteractionsData;
156 exports.skipInteraction = skipInteraction;
157 exports.timingValueToMs = timingValueToMs;
158 exports.unwrapInteractionValue = unwrapInteractionValue;
159 exports.waitForAnimateFunction = waitForAnimateFunction;
160 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
161 var _interactionsBreakpoints = __webpack_require__(/*! ./interactions-breakpoints.js */ "../modules/interactions/assets/js/interactions-breakpoints.js");
162 function config() {
163 var _window$ElementorInte, _window$ElementorInte2;
164 return (_window$ElementorInte = (_window$ElementorInte2 = window.ElementorInteractionsConfig) === null || _window$ElementorInte2 === void 0 ? void 0 : _window$ElementorInte2.constants) !== null && _window$ElementorInte !== void 0 ? _window$ElementorInte : {};
165 }
166 function skipInteraction(interaction) {
167 var _interaction$breakpoi;
168 var breakpoint = (0, _interactionsBreakpoints.getActiveBreakpoint)();
169 return interaction === null || interaction === void 0 || (_interaction$breakpoi = interaction.breakpoints) === null || _interaction$breakpoi === void 0 || (_interaction$breakpoi = _interaction$breakpoi.excluded) === null || _interaction$breakpoi === void 0 ? void 0 : _interaction$breakpoi.includes(breakpoint);
170 }
171 function extractInteractionId(interaction) {
172 if ('interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value) {
173 var _interaction$value$in;
174 return ((_interaction$value$in = interaction.value.interaction_id) === null || _interaction$value$in === void 0 ? void 0 : _interaction$value$in.value) || null;
175 }
176 return null;
177 }
178 function motionFunc(name) {
179 var _window, _window2;
180 if ('function' !== typeof ((_window = window) === null || _window === void 0 || (_window = _window.Motion) === null || _window === void 0 ? void 0 : _window[name])) {
181 return undefined;
182 }
183 return (_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.Motion) === null || _window2 === void 0 ? void 0 : _window2[name];
184 }
185 function getAnimateFunction() {
186 return motionFunc('animate');
187 }
188 function getInViewFunction() {
189 return motionFunc('inView');
190 }
191 function waitForAnimateFunction(callback) {
192 var maxAttempts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
193 if (getAnimateFunction()) {
194 callback();
195 return;
196 }
197 if (maxAttempts > 0) {
198 setTimeout(function () {
199 return waitForAnimateFunction(callback, maxAttempts - 1);
200 }, 100);
201 }
202 }
203 function parseInteractionsData(data) {
204 if ('string' === typeof data) {
205 try {
206 return JSON.parse(data);
207 } catch (_unused) {
208 return null;
209 }
210 }
211 return data;
212 }
213 function unwrapInteractionValue(propValue) {
214 var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
215 // Supports Elementor's typed wrapper shape: { $$type: '...', value: ... }.
216 if (propValue && 'object' === (0, _typeof2.default)(propValue) && '$$type' in propValue) {
217 return propValue.value;
218 }
219 return propValue !== null && propValue !== void 0 ? propValue : fallback;
220 }
221 function timingValueToMs(timingValue, fallbackMs) {
222 if (null === timingValue || undefined === timingValue) {
223 return fallbackMs;
224 }
225 var unwrapped = unwrapInteractionValue(timingValue);
226 if ('number' === typeof unwrapped) {
227 return unwrapped;
228 }
229 var sizeObj = unwrapInteractionValue(unwrapped);
230 var size = sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.size;
231 var unit = (sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.unit) || 'ms';
232 if ('number' !== typeof size) {
233 return fallbackMs;
234 }
235 if ('s' === unit) {
236 return size * 1000;
237 }
238 return size;
239 }
240
241 // Expose on elementorModules for Pro and other consumers.
242 window.elementorModules = window.elementorModules || {};
243 window.elementorModules.interactions = {
244 config: config,
245 skipInteraction: skipInteraction,
246 extractInteractionId: extractInteractionId,
247 getAnimateFunction: getAnimateFunction,
248 getInViewFunction: getInViewFunction,
249 waitForAnimateFunction: waitForAnimateFunction,
250 parseInteractionsData: parseInteractionsData,
251 unwrapInteractionValue: unwrapInteractionValue,
252 timingValueToMs: timingValueToMs
253 };
254 })();
255
256 /******/ })()
257 ;
258 //# sourceMappingURL=interactions-shared-utils.js.map