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.js

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

707 lines 27.1 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 /***/ "../modules/interactions/assets/js/interactions-shared-utils.js":
77 /*!**********************************************************************!*\
78 !*** ../modules/interactions/assets/js/interactions-shared-utils.js ***!
79 \**********************************************************************/
80 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
81
82 "use strict";
83
84
85 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
86 Object.defineProperty(exports, "__esModule", ({
87 value: true
88 }));
89 exports.config = config;
90 exports.extractInteractionId = extractInteractionId;
91 exports.getAnimateFunction = getAnimateFunction;
92 exports.getInViewFunction = getInViewFunction;
93 exports.parseInteractionsData = parseInteractionsData;
94 exports.skipInteraction = skipInteraction;
95 exports.timingValueToMs = timingValueToMs;
96 exports.unwrapInteractionValue = unwrapInteractionValue;
97 exports.waitForAnimateFunction = waitForAnimateFunction;
98 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
99 var _interactionsBreakpoints = __webpack_require__(/*! ./interactions-breakpoints.js */ "../modules/interactions/assets/js/interactions-breakpoints.js");
100 function config() {
101 var _window$ElementorInte, _window$ElementorInte2;
102 return (_window$ElementorInte = (_window$ElementorInte2 = window.ElementorInteractionsConfig) === null || _window$ElementorInte2 === void 0 ? void 0 : _window$ElementorInte2.constants) !== null && _window$ElementorInte !== void 0 ? _window$ElementorInte : {};
103 }
104 function skipInteraction(interaction) {
105 var _interaction$breakpoi;
106 var breakpoint = (0, _interactionsBreakpoints.getActiveBreakpoint)();
107 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);
108 }
109 function extractInteractionId(interaction) {
110 if ('interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value) {
111 var _interaction$value$in;
112 return ((_interaction$value$in = interaction.value.interaction_id) === null || _interaction$value$in === void 0 ? void 0 : _interaction$value$in.value) || null;
113 }
114 return null;
115 }
116 function motionFunc(name) {
117 var _window, _window2;
118 if ('function' !== typeof ((_window = window) === null || _window === void 0 || (_window = _window.Motion) === null || _window === void 0 ? void 0 : _window[name])) {
119 return undefined;
120 }
121 return (_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.Motion) === null || _window2 === void 0 ? void 0 : _window2[name];
122 }
123 function getAnimateFunction() {
124 return motionFunc('animate');
125 }
126 function getInViewFunction() {
127 return motionFunc('inView');
128 }
129 function waitForAnimateFunction(callback) {
130 var maxAttempts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
131 if (getAnimateFunction()) {
132 callback();
133 return;
134 }
135 if (maxAttempts > 0) {
136 setTimeout(function () {
137 return waitForAnimateFunction(callback, maxAttempts - 1);
138 }, 100);
139 }
140 }
141 function parseInteractionsData(data) {
142 if ('string' === typeof data) {
143 try {
144 return JSON.parse(data);
145 } catch (_unused) {
146 return null;
147 }
148 }
149 return data;
150 }
151 function unwrapInteractionValue(propValue) {
152 var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
153 // Supports Elementor's typed wrapper shape: { $$type: '...', value: ... }.
154 if (propValue && 'object' === (0, _typeof2.default)(propValue) && '$$type' in propValue) {
155 return propValue.value;
156 }
157 return propValue !== null && propValue !== void 0 ? propValue : fallback;
158 }
159 function timingValueToMs(timingValue, fallbackMs) {
160 if (null === timingValue || undefined === timingValue) {
161 return fallbackMs;
162 }
163 var unwrapped = unwrapInteractionValue(timingValue);
164 if ('number' === typeof unwrapped) {
165 return unwrapped;
166 }
167 var sizeObj = unwrapInteractionValue(unwrapped);
168 var size = sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.size;
169 var unit = (sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.unit) || 'ms';
170 if ('number' !== typeof size) {
171 return fallbackMs;
172 }
173 if ('s' === unit) {
174 return size * 1000;
175 }
176 return size;
177 }
178
179 // Expose on elementorModules for Pro and other consumers.
180 window.elementorModules = window.elementorModules || {};
181 window.elementorModules.interactions = {
182 config: config,
183 skipInteraction: skipInteraction,
184 extractInteractionId: extractInteractionId,
185 getAnimateFunction: getAnimateFunction,
186 getInViewFunction: getInViewFunction,
187 waitForAnimateFunction: waitForAnimateFunction,
188 parseInteractionsData: parseInteractionsData,
189 unwrapInteractionValue: unwrapInteractionValue,
190 timingValueToMs: timingValueToMs
191 };
192
193 /***/ }),
194
195 /***/ "../modules/interactions/assets/js/interactions-utils.js":
196 /*!***************************************************************!*\
197 !*** ../modules/interactions/assets/js/interactions-utils.js ***!
198 \***************************************************************/
199 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
200
201 "use strict";
202
203
204 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
205 Object.defineProperty(exports, "__esModule", ({
206 value: true
207 }));
208 Object.defineProperty(exports, "config", ({
209 enumerable: true,
210 get: function get() {
211 return _interactionsSharedUtils.config;
212 }
213 }));
214 exports.extractAnimationConfig = extractAnimationConfig;
215 Object.defineProperty(exports, "extractInteractionId", ({
216 enumerable: true,
217 get: function get() {
218 return _interactionsSharedUtils.extractInteractionId;
219 }
220 }));
221 exports.findElementByDataId = findElementByDataId;
222 Object.defineProperty(exports, "getAnimateFunction", ({
223 enumerable: true,
224 get: function get() {
225 return _interactionsSharedUtils.getAnimateFunction;
226 }
227 }));
228 Object.defineProperty(exports, "getInViewFunction", ({
229 enumerable: true,
230 get: function get() {
231 return _interactionsSharedUtils.getInViewFunction;
232 }
233 }));
234 exports.getInteractionsData = getInteractionsData;
235 exports.getKeyframes = getKeyframes;
236 exports.isFreeFrontendSupportedTrigger = isFreeFrontendSupportedTrigger;
237 exports.parseAnimationName = parseAnimationName;
238 Object.defineProperty(exports, "parseInteractionsData", ({
239 enumerable: true,
240 get: function get() {
241 return _interactionsSharedUtils.parseInteractionsData;
242 }
243 }));
244 Object.defineProperty(exports, "skipInteraction", ({
245 enumerable: true,
246 get: function get() {
247 return _interactionsSharedUtils.skipInteraction;
248 }
249 }));
250 Object.defineProperty(exports, "timingValueToMs", ({
251 enumerable: true,
252 get: function get() {
253 return _interactionsSharedUtils.timingValueToMs;
254 }
255 }));
256 Object.defineProperty(exports, "unwrapInteractionValue", ({
257 enumerable: true,
258 get: function get() {
259 return _interactionsSharedUtils.unwrapInteractionValue;
260 }
261 }));
262 Object.defineProperty(exports, "waitForAnimateFunction", ({
263 enumerable: true,
264 get: function get() {
265 return _interactionsSharedUtils.waitForAnimateFunction;
266 }
267 }));
268 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
269 var _interactionsSharedUtils = __webpack_require__(/*! ./interactions-shared-utils.js */ "../modules/interactions/assets/js/interactions-shared-utils.js");
270 /**
271 * Triggers the Core `interactions.js` / `editor-interactions.js` bundles run. Pro-only triggers
272 * (e.g. hover, click) must not fall through to the load-time default path.
273 */
274 var FREE_FRONTEND_SUPPORTED_TRIGGERS = ['load', 'scrollIn', 'scrollOut'];
275 function isFreeFrontendSupportedTrigger(trigger) {
276 return FREE_FRONTEND_SUPPORTED_TRIGGERS.includes(trigger);
277 }
278 function getKeyframes(effect, type, direction) {
279 var isIn = 'in' === type;
280 var keyframes = {};
281 if ('fade' === effect) {
282 keyframes.opacity = isIn ? [0, 1] : [1, 0];
283 }
284 var config = (0, _interactionsSharedUtils.config)();
285 if ('scale' === effect) {
286 keyframes.scale = isIn ? [config.scaleStart, 1] : [1, config.scaleStart];
287 }
288 if (direction) {
289 var distance = config.slideDistance;
290 var movement = {
291 left: {
292 x: isIn ? [-distance, 0] : [0, -distance]
293 },
294 right: {
295 x: isIn ? [distance, 0] : [0, distance]
296 },
297 top: {
298 y: isIn ? [-distance, 0] : [0, -distance]
299 },
300 bottom: {
301 y: isIn ? [distance, 0] : [0, distance]
302 }
303 };
304 Object.assign(keyframes, movement[direction]);
305 }
306 return keyframes;
307 }
308 function parseAnimationName(name) {
309 var _name$split = name.split('-'),
310 _name$split2 = (0, _slicedToArray2.default)(_name$split, 8),
311 trigger = _name$split2[0],
312 effect = _name$split2[1],
313 type = _name$split2[2],
314 direction = _name$split2[3],
315 duration = _name$split2[4],
316 delay = _name$split2[5];
317 var config = (0, _interactionsSharedUtils.config)();
318 return {
319 trigger: trigger,
320 effect: effect,
321 type: type,
322 direction: direction || null,
323 duration: duration ? parseInt(duration, 10) : config.defaultDuration,
324 delay: delay ? parseInt(delay, 10) : config.defaultDelay,
325 replay: false,
326 easing: config.defaultEasing
327 };
328 }
329
330 /**
331 * Get interactions data from the script tag injected by PHP.
332 * Returns array of { elementId, dataId, interactions: [...] }
333 */
334 function getInteractionsData() {
335 var scriptTag = document.getElementById('elementor-interactions-data');
336 if (!scriptTag) {
337 return null;
338 }
339 try {
340 return JSON.parse(scriptTag.textContent);
341 } catch (_unused) {
342 return null;
343 }
344 }
345 function findElementByDataId(dataId) {
346 return document.querySelector("[data-interaction-id=\"".concat(dataId, "\"]"));
347 }
348 function unwrapInteractionBreakpoints(propValue) {
349 var breakpointsConfig = (0, _interactionsSharedUtils.unwrapInteractionValue)(propValue, {});
350 var excluded = (0, _interactionsSharedUtils.unwrapInteractionValue)(breakpointsConfig === null || breakpointsConfig === void 0 ? void 0 : breakpointsConfig.excluded, []);
351 if (1 > excluded.length) {
352 return {};
353 }
354 var breakpoints = {
355 excluded: excluded.map(function (breakpoint) {
356 return (0, _interactionsSharedUtils.unwrapInteractionValue)(breakpoint, '');
357 })
358 };
359 return breakpoints;
360 }
361 function extractAnimationConfig(interaction) {
362 var _payload$animation;
363 if ('string' === typeof interaction) {
364 return parseAnimationName(interaction);
365 }
366 var payload = 'interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value ? interaction.value : interaction;
367 if (!payload) {
368 return null;
369 }
370 if (payload !== null && payload !== void 0 && (_payload$animation = payload.animation) !== null && _payload$animation !== void 0 && _payload$animation.animation_id) {
371 return parseAnimationName(payload.animation.animation_id);
372 }
373 var trigger = (0, _interactionsSharedUtils.unwrapInteractionValue)(payload.trigger) || payload.trigger || 'load';
374 var animation = payload.animation;
375 animation = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation);
376 if (!animation) {
377 return null;
378 }
379 var breakpoints = unwrapInteractionBreakpoints(payload.breakpoints);
380 var config = (0, _interactionsSharedUtils.config)();
381 var effect = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.effect) || animation.effect || 'fade';
382 var type = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.type) || animation.type || 'in';
383 var direction = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.direction) || animation.direction || '';
384 var easing = config.defaultEasing;
385 var replay = false;
386 var timingConfig = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.timing_config) || animation.timing_config || {};
387 var duration = (0, _interactionsSharedUtils.timingValueToMs)(timingConfig === null || timingConfig === void 0 ? void 0 : timingConfig.duration, config.defaultDuration);
388 var delay = (0, _interactionsSharedUtils.timingValueToMs)(timingConfig === null || timingConfig === void 0 ? void 0 : timingConfig.delay, config.defaultDelay);
389 return {
390 trigger: trigger,
391 breakpoints: breakpoints,
392 effect: effect,
393 type: type,
394 direction: direction,
395 duration: duration,
396 delay: delay,
397 easing: easing,
398 replay: replay
399 };
400 }
401
402 /***/ }),
403
404 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
405 /*!******************************************************************!*\
406 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
407 \******************************************************************/
408 /***/ ((module) => {
409
410 function _arrayLikeToArray(r, a) {
411 (null == a || a > r.length) && (a = r.length);
412 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
413 return n;
414 }
415 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
416
417 /***/ }),
418
419 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
420 /*!****************************************************************!*\
421 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
422 \****************************************************************/
423 /***/ ((module) => {
424
425 function _arrayWithHoles(r) {
426 if (Array.isArray(r)) return r;
427 }
428 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
429
430 /***/ }),
431
432 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
433 /*!***********************************************************************!*\
434 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
435 \***********************************************************************/
436 /***/ ((module) => {
437
438 function _interopRequireDefault(e) {
439 return e && e.__esModule ? e : {
440 "default": e
441 };
442 }
443 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
444
445 /***/ }),
446
447 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
448 /*!**********************************************************************!*\
449 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
450 \**********************************************************************/
451 /***/ ((module) => {
452
453 function _iterableToArrayLimit(r, l) {
454 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
455 if (null != t) {
456 var e,
457 n,
458 i,
459 u,
460 a = [],
461 f = !0,
462 o = !1;
463 try {
464 if (i = (t = t.call(r)).next, 0 === l) {
465 if (Object(t) !== t) return;
466 f = !1;
467 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
468 } catch (r) {
469 o = !0, n = r;
470 } finally {
471 try {
472 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
473 } finally {
474 if (o) throw n;
475 }
476 }
477 return a;
478 }
479 }
480 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
481
482 /***/ }),
483
484 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
485 /*!*****************************************************************!*\
486 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
487 \*****************************************************************/
488 /***/ ((module) => {
489
490 function _nonIterableRest() {
491 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
492 }
493 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
494
495 /***/ }),
496
497 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
498 /*!***************************************************************!*\
499 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
500 \***************************************************************/
501 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
502
503 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
504 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
505 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
506 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
507 function _slicedToArray(r, e) {
508 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
509 }
510 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
511
512 /***/ }),
513
514 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
515 /*!********************************************************!*\
516 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
517 \********************************************************/
518 /***/ ((module) => {
519
520 function _typeof(o) {
521 "@babel/helpers - typeof";
522
523 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
524 return typeof o;
525 } : function (o) {
526 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
527 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
528 }
529 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
530
531 /***/ }),
532
533 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
534 /*!****************************************************************************!*\
535 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
536 \****************************************************************************/
537 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
538
539 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
540 function _unsupportedIterableToArray(r, a) {
541 if (r) {
542 if ("string" == typeof r) return arrayLikeToArray(r, a);
543 var t = {}.toString.call(r).slice(8, -1);
544 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;
545 }
546 }
547 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
548
549 /***/ })
550
551 /******/ });
552 /************************************************************************/
553 /******/ // The module cache
554 /******/ var __webpack_module_cache__ = {};
555 /******/
556 /******/ // The require function
557 /******/ function __webpack_require__(moduleId) {
558 /******/ // Check if module is in cache
559 /******/ var cachedModule = __webpack_module_cache__[moduleId];
560 /******/ if (cachedModule !== undefined) {
561 /******/ return cachedModule.exports;
562 /******/ }
563 /******/ // Create a new module (and put it into the cache)
564 /******/ var module = __webpack_module_cache__[moduleId] = {
565 /******/ // no module.id needed
566 /******/ // no module.loaded needed
567 /******/ exports: {}
568 /******/ };
569 /******/
570 /******/ // Execute the module function
571 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
572 /******/
573 /******/ // Return the exports of the module
574 /******/ return module.exports;
575 /******/ }
576 /******/
577 /************************************************************************/
578 var __webpack_exports__ = {};
579 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
580 (() => {
581 "use strict";
582 /*!*********************************************************!*\
583 !*** ../modules/interactions/assets/js/interactions.js ***!
584 \*********************************************************/
585
586
587 var _interactionsUtils = __webpack_require__(/*! ./interactions-utils.js */ "../modules/interactions/assets/js/interactions-utils.js");
588 var _interactionsBreakpoints = __webpack_require__(/*! ./interactions-breakpoints.js */ "../modules/interactions/assets/js/interactions-breakpoints.js");
589 function scrollOutAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc) {
590 var viewOptions = {
591 amount: 0.85,
592 root: null
593 };
594 var resetKeyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, 'in', animConfig.direction);
595 animateFunc(element, resetKeyframes, {
596 duration: 0
597 });
598 var stop = inViewFunc(element, function () {
599 return function () {
600 animateFunc(element, keyframes, options).then(function () {
601 element.style.transition = transition;
602 });
603 if (false === animConfig.replay) {
604 stop();
605 }
606 };
607 }, viewOptions);
608 }
609 function scrollInAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc) {
610 var viewOptions = {
611 amount: 0,
612 root: null
613 };
614 var stop = inViewFunc(element, function () {
615 animateFunc(element, keyframes, options).then(function () {
616 element.style.transition = transition;
617 });
618 if (false === animConfig.replay) {
619 stop();
620 }
621 }, viewOptions);
622 }
623 function defaultAnimation(element, transition, keyframes, options, animateFunc) {
624 animateFunc(element, keyframes, options).then(function () {
625 element.style.transition = transition;
626 });
627 }
628 function applyAnimation(element, animConfig, animateFunc, inViewFunc) {
629 var keyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, animConfig.type, animConfig.direction);
630 var options = {
631 duration: animConfig.duration / 1000,
632 delay: animConfig.delay / 1000,
633 ease: (0, _interactionsUtils.config)().defaultEasing
634 };
635
636 // WHY - Transition can be set on elements but once it sets it destroys all animations, so we basically put it aside.
637 var transition = element.style.transition;
638 element.style.transition = 'none';
639 if ('scrollOut' === animConfig.trigger) {
640 scrollOutAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc);
641 } else if ('scrollIn' === animConfig.trigger) {
642 scrollInAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc);
643 } else {
644 defaultAnimation(element, transition, keyframes, options, animateFunc);
645 }
646 }
647 function processElementInteractions(element, interactions, animateFunc, inViewFunc) {
648 if (!interactions || !Array.isArray(interactions)) {
649 return;
650 }
651 interactions.forEach(function (interaction) {
652 var animConfig = (0, _interactionsUtils.extractAnimationConfig)(interaction);
653 if (animConfig && !(0, _interactionsUtils.skipInteraction)(animConfig) && (0, _interactionsUtils.isFreeFrontendSupportedTrigger)(animConfig.trigger)) {
654 applyAnimation(element, animConfig, animateFunc, inViewFunc);
655 }
656 });
657 }
658 function initInteractions() {
659 (0, _interactionsUtils.waitForAnimateFunction)(function () {
660 var animateFunc = (0, _interactionsUtils.getAnimateFunction)();
661 var inViewFunc = (0, _interactionsUtils.getInViewFunction)();
662 if (!inViewFunc || !animateFunc) {
663 return;
664 }
665
666 // New method: Read centralized interactions data from script tag
667 var dataScript = document.getElementById('elementor-interactions-data');
668 if (dataScript) {
669 var elementsData = JSON.parse(dataScript.textContent);
670 elementsData.forEach(function (elementData) {
671 var elementId = elementData.elementId,
672 interactions = elementData.interactions;
673 if (!elementId || !interactions || !Array.isArray(interactions)) {
674 return;
675 }
676 var element = document.querySelector("[data-interaction-id=\"".concat(elementId, "\"]"));
677 if (!element) {
678 return;
679 }
680 processElementInteractions(element, interactions, animateFunc, inViewFunc);
681 });
682 return;
683 }
684
685 // Legacy fallback: parse data-interactions attributes
686 var elements = document.querySelectorAll('[data-interactions]');
687 elements.forEach(function (element) {
688 var interactionsData = element.getAttribute('data-interactions');
689 var parsedData = (0, _interactionsUtils.parseInteractionsData)(interactionsData);
690 processElementInteractions(element, parsedData, animateFunc, inViewFunc);
691 });
692 });
693 }
694 function init() {
695 (0, _interactionsBreakpoints.initBreakpoints)();
696 initInteractions();
697 }
698 if ('loading' === document.readyState) {
699 document.addEventListener('DOMContentLoaded', init);
700 } else {
701 init();
702 }
703 })();
704
705 /******/ })()
706 ;
707 //# sourceMappingURL=interactions.js.map