PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.0-beta1
Elementor Website Builder – more than just a page builder v3.34.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
← All changes | assets/js/editor-interactions.js +158 -629 4.2.0-dev2 → 3.34.0-beta1 View file →
@@ -1,382 +1,7 @@
1 1 /******/ (() => { // webpackBootstrap
2 2 /******/ var __webpack_modules__ = ({
3 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.getTransformBaselineFromComputedStyle = getTransformBaselineFromComputedStyle;
94 -exports.parseInteractionsData = parseInteractionsData;
95 -exports.preserveTransformKeyframes = preserveTransformKeyframes;
96 -exports.resetElementStyles = resetElementStyles;
97 -exports.skipInteraction = skipInteraction;
98 -exports.timingValueToMs = timingValueToMs;
99 -exports.unwrapInteractionValue = unwrapInteractionValue;
100 -exports.waitForAnimateFunction = waitForAnimateFunction;
101 -var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
102 -var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
103 -var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
104 -var _interactionsBreakpoints = __webpack_require__(/*! ./interactions-breakpoints.js */ "../modules/interactions/assets/js/interactions-breakpoints.js");
105 -function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
106 -function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
107 -function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
108 -function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); 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; } }
109 -function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
110 -function config() {
111 - var _window$ElementorInte, _window$ElementorInte2;
112 - return (_window$ElementorInte = (_window$ElementorInte2 = window.ElementorInteractionsConfig) === null || _window$ElementorInte2 === void 0 ? void 0 : _window$ElementorInte2.constants) !== null && _window$ElementorInte !== void 0 ? _window$ElementorInte : {};
113 -}
114 -function skipInteraction(interaction) {
115 - var _interaction$breakpoi;
116 - var breakpoint = (0, _interactionsBreakpoints.getActiveBreakpoint)();
117 - 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);
118 -}
119 -function extractInteractionId(interaction) {
120 - if ('interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value) {
121 - var _interaction$value$in;
122 - return ((_interaction$value$in = interaction.value.interaction_id) === null || _interaction$value$in === void 0 ? void 0 : _interaction$value$in.value) || null;
123 - }
124 - return null;
125 -}
126 -function motionFunc(name) {
127 - var _window, _window2;
128 - if ('function' !== typeof ((_window = window) === null || _window === void 0 || (_window = _window.Motion) === null || _window === void 0 ? void 0 : _window[name])) {
129 - return undefined;
130 - }
131 - return (_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.Motion) === null || _window2 === void 0 ? void 0 : _window2[name];
132 -}
133 -function getAnimateFunction() {
134 - return motionFunc('animate');
135 -}
136 -function getInViewFunction() {
137 - return motionFunc('inView');
138 -}
139 -function waitForAnimateFunction(callback) {
140 - var maxAttempts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
141 - if (getAnimateFunction()) {
142 - callback();
143 - return;
144 - }
145 - if (maxAttempts > 0) {
146 - setTimeout(function () {
147 - return waitForAnimateFunction(callback, maxAttempts - 1);
148 - }, 100);
149 - }
150 -}
151 -function parseInteractionsData(data) {
152 - if ('string' === typeof data) {
153 - try {
154 - return JSON.parse(data);
155 - } catch (_unused) {
156 - return null;
157 - }
158 - }
159 - return data;
160 -}
161 -function unwrapInteractionValue(propValue) {
162 - var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
163 - // Supports Elementor's typed wrapper shape: { $$type: '...', value: ... }.
164 - if (propValue && 'object' === (0, _typeof2.default)(propValue) && '$$type' in propValue) {
165 - return propValue.value;
166 - }
167 - return propValue !== null && propValue !== void 0 ? propValue : fallback;
168 -}
169 -function timingValueToMs(timingValue, fallbackMs) {
170 - if (null === timingValue || undefined === timingValue) {
171 - return fallbackMs;
172 - }
173 - var unwrapped = unwrapInteractionValue(timingValue);
174 - if ('number' === typeof unwrapped) {
175 - return unwrapped;
176 - }
177 - var sizeObj = unwrapInteractionValue(unwrapped);
178 - var size = sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.size;
179 - var unit = (sizeObj === null || sizeObj === void 0 ? void 0 : sizeObj.unit) || 'ms';
180 - if ('number' !== typeof size) {
181 - return fallbackMs;
182 - }
183 - if ('s' === unit) {
184 - return size * 1000;
185 - }
186 - return size;
187 -}
188 -function resetElementStyles(element) {
189 - if (!element) {
190 - return;
191 - }
192 - element.style.transition = '';
193 - element.style.transform = '';
194 - element.style.opacity = '';
195 -}
196 -var TRANSFORM_EPSILON = 0.001;
197 -var radiansToDegrees = function radiansToDegrees(radians) {
198 - return radians * (180 / Math.PI);
199 -};
200 -var isNear = function isNear(value, expected) {
201 - return Math.abs(value - expected) <= TRANSFORM_EPSILON;
202 -};
203 -var isNearZero = function isNearZero(value) {
204 - return isNear(value, 0);
205 -};
206 -var isNearOne = function isNearOne(value) {
207 - return isNear(value, 1);
208 -};
209 -function parseMatrixValues(transformValue) {
210 - var match = transformValue.match(/^matrix(3d)?\((.+)\)$/);
211 - if (!match) {
212 - return null;
213 - }
214 - return match[2].split(',').map(function (token) {
215 - return Number.parseFloat(token.trim());
216 - }).filter(function (value) {
217 - return Number.isFinite(value);
218 - });
219 -}
220 -function createMatrixFromTransform(transformValue) {
221 - if (!transformValue || 'none' === transformValue) {
222 - return null;
223 - }
224 - var matrixFactories = [window.DOMMatrixReadOnly, window.DOMMatrix].filter(function (Factory) {
225 - return 'function' === typeof Factory;
226 - });
227 - var _iterator = _createForOfIteratorHelper(matrixFactories),
228 - _step;
229 - try {
230 - for (_iterator.s(); !(_step = _iterator.n()).done;) {
231 - var MatrixFactory = _step.value;
232 - try {
233 - var _ref, _matrix$a, _ref2, _matrix$b, _ref3, _matrix$c, _ref4, _matrix$d, _ref5, _matrix$e, _ref6, _matrix$f;
234 - var matrix = new MatrixFactory(transformValue);
235 - // CSS matrix(a,b,c,d,e,f): x' = ax + cy + e, y' = bx + dy + f
236 - // matrixXfromY = how much input Y contributes to output X (etc.)
237 - var compactMatrix = {
238 - matrixXfromX: (_ref = (_matrix$a = matrix.a) !== null && _matrix$a !== void 0 ? _matrix$a : matrix.m11) !== null && _ref !== void 0 ? _ref : 1,
239 - matrixYfromX: (_ref2 = (_matrix$b = matrix.b) !== null && _matrix$b !== void 0 ? _matrix$b : matrix.m12) !== null && _ref2 !== void 0 ? _ref2 : 0,
240 - matrixXfromY: (_ref3 = (_matrix$c = matrix.c) !== null && _matrix$c !== void 0 ? _matrix$c : matrix.m21) !== null && _ref3 !== void 0 ? _ref3 : 0,
241 - matrixYfromY: (_ref4 = (_matrix$d = matrix.d) !== null && _matrix$d !== void 0 ? _matrix$d : matrix.m22) !== null && _ref4 !== void 0 ? _ref4 : 1,
242 - matrixTranslateX: (_ref5 = (_matrix$e = matrix.e) !== null && _matrix$e !== void 0 ? _matrix$e : matrix.m41) !== null && _ref5 !== void 0 ? _ref5 : 0,
243 - matrixTranslateY: (_ref6 = (_matrix$f = matrix.f) !== null && _matrix$f !== void 0 ? _matrix$f : matrix.m42) !== null && _ref6 !== void 0 ? _ref6 : 0
244 - };
245 - if (Object.values(compactMatrix).every(Number.isFinite)) {
246 - return compactMatrix;
247 - }
248 - } catch (_unused2) {}
249 - }
250 - } catch (err) {
251 - _iterator.e(err);
252 - } finally {
253 - _iterator.f();
254 - }
255 - var parsedValues = parseMatrixValues(transformValue);
256 - if (!parsedValues) {
257 - return null;
258 - }
259 - if (6 === parsedValues.length) {
260 - var _parsedValues = (0, _slicedToArray2.default)(parsedValues, 6),
261 - matrixXfromX = _parsedValues[0],
262 - matrixYfromX = _parsedValues[1],
263 - matrixXfromY = _parsedValues[2],
264 - matrixYfromY = _parsedValues[3],
265 - matrixTranslateX = _parsedValues[4],
266 - matrixTranslateY = _parsedValues[5];
267 - return {
268 - matrixXfromX: matrixXfromX,
269 - matrixYfromX: matrixYfromX,
270 - matrixXfromY: matrixXfromY,
271 - matrixYfromY: matrixYfromY,
272 - matrixTranslateX: matrixTranslateX,
273 - matrixTranslateY: matrixTranslateY
274 - };
275 - }
276 - if (16 === parsedValues.length) {
277 - var _parsedValues2 = (0, _slicedToArray2.default)(parsedValues, 14),
278 - _matrixXfromX = _parsedValues2[0],
279 - _matrixYfromX = _parsedValues2[1],
280 - _matrixXfromY = _parsedValues2[4],
281 - _matrixYfromY = _parsedValues2[5],
282 - _matrixTranslateX = _parsedValues2[12],
283 - _matrixTranslateY = _parsedValues2[13];
284 - return {
285 - matrixXfromX: _matrixXfromX,
286 - matrixYfromX: _matrixYfromX,
287 - matrixXfromY: _matrixXfromY,
288 - matrixYfromY: _matrixYfromY,
289 - matrixTranslateX: _matrixTranslateX,
290 - matrixTranslateY: _matrixTranslateY
291 - };
292 - }
293 - return null;
294 -}
295 -function getTransformBaselineFromComputedStyle(element) {
296 - if (!element) {
297 - return null;
298 - }
299 - var computedStyle = window.getComputedStyle(element);
300 - var matrix = createMatrixFromTransform((computedStyle === null || computedStyle === void 0 ? void 0 : computedStyle.transform) || '');
301 - if (!matrix) {
302 - return null;
303 - }
304 - var matrixXfromX = matrix.matrixXfromX,
305 - matrixYfromX = matrix.matrixYfromX,
306 - matrixXfromY = matrix.matrixXfromY,
307 - matrixYfromY = matrix.matrixYfromY,
308 - matrixTranslateX = matrix.matrixTranslateX,
309 - matrixTranslateY = matrix.matrixTranslateY;
310 - var scaleX = Math.hypot(matrixXfromX, matrixYfromX);
311 - var determinant = matrixXfromX * matrixYfromY - matrixYfromX * matrixXfromY;
312 - var scaleY = scaleX ? determinant / scaleX : Math.hypot(matrixXfromY, matrixYfromY);
313 - var rotate = radiansToDegrees(Math.atan2(matrixYfromX, matrixXfromX));
314 - var shear = scaleX ? (matrixXfromX * matrixXfromY + matrixYfromX * matrixYfromY) / (scaleX * scaleX) : 0;
315 - var skewX = radiansToDegrees(Math.atan(shear));
316 - return {
317 - x: matrixTranslateX,
318 - y: matrixTranslateY,
319 - scaleX: Number.isFinite(scaleX) ? scaleX : 1,
320 - scaleY: Number.isFinite(scaleY) ? scaleY : 1,
321 - rotate: Number.isFinite(rotate) ? rotate : 0,
322 - skewX: Number.isFinite(skewX) ? skewX : 0
323 - };
324 -}
325 -function preserveTransformKeyframes(keyframes, baseline) {
326 - if (!baseline) {
327 - return keyframes;
328 - }
329 - var mergedKeyframes = _objectSpread({}, keyframes);
330 - var hasScaleShorthand = mergedKeyframes.scale !== undefined;
331 - var canSetScaleX = mergedKeyframes.scaleX === undefined && !isNearOne(baseline.scaleX);
332 - var canSetScaleY = mergedKeyframes.scaleY === undefined && !isNearOne(baseline.scaleY);
333 - if (mergedKeyframes.x === undefined && !isNearZero(baseline.x)) {
334 - mergedKeyframes.x = [baseline.x, baseline.x];
335 - }
336 - if (mergedKeyframes.y === undefined && !isNearZero(baseline.y)) {
337 - mergedKeyframes.y = [baseline.y, baseline.y];
338 - }
339 - if (!hasScaleShorthand) {
340 - if (canSetScaleX && canSetScaleY && isNear(baseline.scaleX, baseline.scaleY)) {
341 - mergedKeyframes.scale = [baseline.scaleX, baseline.scaleX];
342 - } else {
343 - if (canSetScaleX) {
344 - mergedKeyframes.scaleX = [baseline.scaleX, baseline.scaleX];
345 - }
346 - if (canSetScaleY) {
347 - mergedKeyframes.scaleY = [baseline.scaleY, baseline.scaleY];
348 - }
349 - }
350 - }
351 - if (mergedKeyframes.rotate === undefined && mergedKeyframes.rotateZ === undefined && !isNearZero(baseline.rotate)) {
352 - mergedKeyframes.rotate = [baseline.rotate, baseline.rotate];
353 - }
354 - if (mergedKeyframes.skew === undefined && mergedKeyframes.skewX === undefined && !isNearZero(baseline.skewX)) {
355 - mergedKeyframes.skewX = [baseline.skewX, baseline.skewX];
356 - }
357 - return mergedKeyframes;
358 -}
359 -
360 -// Expose on elementorModules for Pro and other consumers.
361 -window.elementorModules = window.elementorModules || {};
362 -window.elementorModules.interactions = {
363 - config: config,
364 - skipInteraction: skipInteraction,
365 - extractInteractionId: extractInteractionId,
366 - getAnimateFunction: getAnimateFunction,
367 - getInViewFunction: getInViewFunction,
368 - waitForAnimateFunction: waitForAnimateFunction,
369 - parseInteractionsData: parseInteractionsData,
370 - unwrapInteractionValue: unwrapInteractionValue,
371 - timingValueToMs: timingValueToMs,
372 - resetElementStyles: resetElementStyles,
373 - getTransformBaselineFromComputedStyle: getTransformBaselineFromComputedStyle,
374 - preserveTransformKeyframes: preserveTransformKeyframes
375 -};
376 -
377 -/***/ }),
378 -
379 4 /***/ "../modules/interactions/assets/js/interactions-utils.js":
380 5 /*!***************************************************************!*\
381 6 !*** ../modules/interactions/assets/js/interactions-utils.js ***!
382 7 \***************************************************************/
@@ -388,97 +13,20 @@
388 13 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
389 14 Object.defineProperty(exports, "__esModule", ({
390 15 value: true
391 16 }));
392 -Object.defineProperty(exports, "config", ({
393 - enumerable: true,
394 - get: function get() {
395 - return _interactionsSharedUtils.config;
396 - }
397 -}));
398 -exports.extractAnimationConfig = extractAnimationConfig;
399 -Object.defineProperty(exports, "extractInteractionId", ({
400 - enumerable: true,
401 - get: function get() {
402 - return _interactionsSharedUtils.extractInteractionId;
403 - }
404 -}));
405 -exports.findElementByDataId = findElementByDataId;
406 -Object.defineProperty(exports, "getAnimateFunction", ({
407 - enumerable: true,
408 - get: function get() {
409 - return _interactionsSharedUtils.getAnimateFunction;
410 - }
411 -}));
412 -Object.defineProperty(exports, "getInViewFunction", ({
413 - enumerable: true,
414 - get: function get() {
415 - return _interactionsSharedUtils.getInViewFunction;
416 - }
417 -}));
418 -exports.getInteractionsData = getInteractionsData;
17 +exports.config = void 0;
419 18 exports.getKeyframes = getKeyframes;
420 -Object.defineProperty(exports, "getTransformBaselineFromComputedStyle", ({
421 - enumerable: true,
422 - get: function get() {
423 - return _interactionsSharedUtils.getTransformBaselineFromComputedStyle;
424 - }
425 -}));
426 19 exports.parseAnimationName = parseAnimationName;
427 -Object.defineProperty(exports, "parseInteractionsData", ({
428 - enumerable: true,
429 - get: function get() {
430 - return _interactionsSharedUtils.parseInteractionsData;
431 - }
432 -}));
433 -Object.defineProperty(exports, "preserveTransformKeyframes", ({
434 - enumerable: true,
435 - get: function get() {
436 - return _interactionsSharedUtils.preserveTransformKeyframes;
437 - }
438 -}));
439 -Object.defineProperty(exports, "resetElementStyles", ({
440 - enumerable: true,
441 - get: function get() {
442 - return _interactionsSharedUtils.resetElementStyles;
443 - }
444 -}));
445 -exports.skipInteraction = skipInteraction;
446 -Object.defineProperty(exports, "timingValueToMs", ({
447 - enumerable: true,
448 - get: function get() {
449 - return _interactionsSharedUtils.timingValueToMs;
450 - }
451 -}));
452 -Object.defineProperty(exports, "unwrapInteractionValue", ({
453 - enumerable: true,
454 - get: function get() {
455 - return _interactionsSharedUtils.unwrapInteractionValue;
456 - }
457 -}));
458 -Object.defineProperty(exports, "waitForAnimateFunction", ({
459 - enumerable: true,
460 - get: function get() {
461 - return _interactionsSharedUtils.waitForAnimateFunction;
462 - }
463 -}));
464 20 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
465 -var _interactionsSharedUtils = __webpack_require__(/*! ./interactions-shared-utils.js */ "../modules/interactions/assets/js/interactions-shared-utils.js");
466 -function isSupportedInteraction(animationConfig) {
467 - if (!['load', 'scrollIn', 'scrollOut'].includes(animationConfig.trigger)) {
468 - return false;
469 - }
470 - if ('custom' === animationConfig.effect) {
471 - return false;
472 - }
473 - return true;
474 -}
475 -function skipInteraction(animationConfig) {
476 - if (!isSupportedInteraction(animationConfig)) {
477 - return true;
478 - }
479 - return (0, _interactionsSharedUtils.skipInteraction)(animationConfig);
480 -}
21 +var _window$ElementorInte;
22 +var config = exports.config = ((_window$ElementorInte = window.ElementorInteractionsConfig) === null || _window$ElementorInte === void 0 ? void 0 : _window$ElementorInte.constants) || {
23 + defaultDuration: 300,
24 + defaultDelay: 0,
25 + slideDistance: 100,
26 + scaleStart: 0,
27 + easing: 'linear'
28 +};
481 29 function getKeyframes(effect, type, direction) {
482 30 var isIn = 'in' === type;
483 31 var keyframes = {};
484 32 if ('fade' === effect) {
@@ -483,13 +31,12 @@
483 31 var keyframes = {};
484 32 if ('fade' === effect) {
485 33 keyframes.opacity = isIn ? [0, 1] : [1, 0];
486 34 }
487 - var config = (0, _interactionsSharedUtils.config)();
488 35 if ('scale' === effect) {
489 36 keyframes.scale = isIn ? [config.scaleStart, 1] : [1, config.scaleStart];
490 37 }
491 - if (direction && 'string' === typeof direction) {
38 + if (direction) {
492 39 var distance = config.slideDistance;
493 40 var movement = {
494 41 left: {
495 42 x: isIn ? [-distance, 0] : [0, -distance]
@@ -503,19 +50,15 @@
503 50 bottom: {
504 51 y: isIn ? [distance, 0] : [0, distance]
505 52 }
506 53 };
507 - direction.split('-').forEach(function (part) {
508 - if (movement[part]) {
509 - Object.assign(keyframes, movement[part]);
510 - }
511 - });
54 + Object.assign(keyframes, movement[direction]);
512 55 }
513 56 return keyframes;
514 57 }
515 58 function parseAnimationName(name) {
516 59 var _name$split = name.split('-'),
517 - _name$split2 = (0, _slicedToArray2.default)(_name$split, 8),
60 + _name$split2 = (0, _slicedToArray2.default)(_name$split, 6),
518 61 trigger = _name$split2[0],
519 62 effect = _name$split2[1],
520 63 type = _name$split2[2],
521 64 direction = _name$split2[3],
@@ -520,9 +63,8 @@
520 63 type = _name$split2[2],
521 64 direction = _name$split2[3],
522 65 duration = _name$split2[4],
523 66 delay = _name$split2[5];
524 - var config = (0, _interactionsSharedUtils.config)();
525 67 return {
526 68 trigger: trigger,
527 69 effect: effect,
528 70 type: type,
@@ -527,87 +69,12 @@
527 69 effect: effect,
528 70 type: type,
529 71 direction: direction || null,
530 72 duration: duration ? parseInt(duration, 10) : config.defaultDuration,
531 - delay: delay ? parseInt(delay, 10) : config.defaultDelay,
532 - replay: false,
533 - easing: config.defaultEasing
73 + delay: delay ? parseInt(delay, 10) : config.defaultDelay
534 74 };
535 75 }
536 76
537 -/**
538 - * Get interactions data from the script tag injected by PHP.
539 - * Returns array of { elementId, dataId, interactions: [...] }
540 - */
541 -function getInteractionsData() {
542 - var scriptTag = document.getElementById('elementor-interactions-data');
543 - if (!scriptTag) {
544 - return null;
545 - }
546 - try {
547 - return JSON.parse(scriptTag.textContent);
548 - } catch (_unused) {
549 - return null;
550 - }
551 -}
552 -function findElementByDataId(dataId) {
553 - return document.querySelector("[data-interaction-id=\"".concat(dataId, "\"]"));
554 -}
555 -function unwrapInteractionBreakpoints(propValue) {
556 - var breakpointsConfig = (0, _interactionsSharedUtils.unwrapInteractionValue)(propValue, {});
557 - var excluded = (0, _interactionsSharedUtils.unwrapInteractionValue)(breakpointsConfig === null || breakpointsConfig === void 0 ? void 0 : breakpointsConfig.excluded, []);
558 - if (1 > excluded.length) {
559 - return {};
560 - }
561 - var breakpoints = {
562 - excluded: excluded.map(function (breakpoint) {
563 - return (0, _interactionsSharedUtils.unwrapInteractionValue)(breakpoint, '');
564 - })
565 - };
566 - return breakpoints;
567 -}
568 -function extractAnimationConfig(interaction) {
569 - var _payload$animation;
570 - if ('string' === typeof interaction) {
571 - return parseAnimationName(interaction);
572 - }
573 - var payload = 'interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value ? interaction.value : interaction;
574 - if (!payload) {
575 - return null;
576 - }
577 - if (payload !== null && payload !== void 0 && (_payload$animation = payload.animation) !== null && _payload$animation !== void 0 && _payload$animation.animation_id) {
578 - return parseAnimationName(payload.animation.animation_id);
579 - }
580 - var trigger = (0, _interactionsSharedUtils.unwrapInteractionValue)(payload.trigger) || payload.trigger || 'load';
581 - var animation = payload.animation;
582 - animation = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation);
583 - if (!animation) {
584 - return null;
585 - }
586 - var breakpoints = unwrapInteractionBreakpoints(payload.breakpoints);
587 - var config = (0, _interactionsSharedUtils.config)();
588 - var effect = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.effect) || animation.effect || 'fade';
589 - var type = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.type) || animation.type || 'in';
590 - var directionUnwrapped = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.direction);
591 - var direction = 'string' === typeof directionUnwrapped ? directionUnwrapped : '';
592 - var easing = config.defaultEasing;
593 - var replay = false;
594 - var timingConfig = (0, _interactionsSharedUtils.unwrapInteractionValue)(animation.timing_config) || animation.timing_config || {};
595 - var duration = (0, _interactionsSharedUtils.timingValueToMs)(timingConfig === null || timingConfig === void 0 ? void 0 : timingConfig.duration, config.defaultDuration);
596 - var delay = (0, _interactionsSharedUtils.timingValueToMs)(timingConfig === null || timingConfig === void 0 ? void 0 : timingConfig.delay, config.defaultDelay);
597 - return {
598 - trigger: trigger,
599 - breakpoints: breakpoints,
600 - effect: effect,
601 - type: type,
602 - direction: direction,
603 - duration: duration,
604 - delay: delay,
605 - easing: easing,
606 - replay: replay
607 - };
608 -}
609 -
610 77 /***/ }),
611 78
612 79 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
613 80 /*!******************************************************************!*\
@@ -636,8 +103,22 @@
636 103 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
637 104
638 105 /***/ }),
639 106
107 +/***/ "../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js":
108 +/*!*******************************************************************!*\
109 + !*** ../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
110 + \*******************************************************************/
111 +/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
112 +
113 +var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
114 +function _arrayWithoutHoles(r) {
115 + if (Array.isArray(r)) return arrayLikeToArray(r);
116 +}
117 +module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
118 +
119 +/***/ }),
120 +
640 121 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
641 122 /*!****************************************************************!*\
642 123 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
643 124 \****************************************************************/
@@ -670,8 +151,21 @@
670 151 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
671 152
672 153 /***/ }),
673 154
155 +/***/ "../node_modules/@babel/runtime/helpers/iterableToArray.js":
156 +/*!*****************************************************************!*\
157 + !*** ../node_modules/@babel/runtime/helpers/iterableToArray.js ***!
158 + \*****************************************************************/
159 +/***/ ((module) => {
160 +
161 +function _iterableToArray(r) {
162 + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
163 +}
164 +module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
165 +
166 +/***/ }),
167 +
674 168 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
675 169 /*!**********************************************************************!*\
676 170 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
677 171 \**********************************************************************/
@@ -720,8 +214,21 @@
720 214 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
721 215
722 216 /***/ }),
723 217
218 +/***/ "../node_modules/@babel/runtime/helpers/nonIterableSpread.js":
219 +/*!*******************************************************************!*\
220 + !*** ../node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
221 + \*******************************************************************/
222 +/***/ ((module) => {
223 +
224 +function _nonIterableSpread() {
225 + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
226 +}
227 +module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
228 +
229 +/***/ }),
230 +
724 231 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
725 232 /*!***************************************************************!*\
726 233 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
727 234 \***************************************************************/
@@ -737,8 +244,25 @@
737 244 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
738 245
739 246 /***/ }),
740 247
248 +/***/ "../node_modules/@babel/runtime/helpers/toConsumableArray.js":
249 +/*!*******************************************************************!*\
250 + !*** ../node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
251 + \*******************************************************************/
252 +/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
253 +
254 +var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js");
255 +var iterableToArray = __webpack_require__(/*! ./iterableToArray.js */ "../node_modules/@babel/runtime/helpers/iterableToArray.js");
256 +var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
257 +var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread.js */ "../node_modules/@babel/runtime/helpers/nonIterableSpread.js");
258 +function _toConsumableArray(r) {
259 + return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();
260 +}
261 +module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
262 +
263 +/***/ }),
264 +
741 265 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
742 266 /*!*************************************************************!*\
743 267 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
744 268 \*************************************************************/
@@ -848,43 +372,47 @@
848 372 \****************************************************************/
849 373
850 374
851 375 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
376 +var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "../node_modules/@babel/runtime/helpers/toConsumableArray.js"));
852 377 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
853 378 var _interactionsUtils = __webpack_require__(/*! ./interactions-utils.js */ "../modules/interactions/assets/js/interactions-utils.js");
854 379 function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
855 380 function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
856 -/**
857 - * @type {Record<string, Promise<void> & { cancel: () => void }>}
858 - */
859 -var playingInteractionsToStop = {};
860 381 function applyAnimation(element, animConfig, animateFunc) {
861 - var id = element.id;
862 - if (playingInteractionsToStop[id]) {
863 - playingInteractionsToStop[id].cancel();
864 - delete playingInteractionsToStop[id];
865 - }
866 - var baseline = (0, _interactionsUtils.getTransformBaselineFromComputedStyle)(element);
867 - var keyframes = (0, _interactionsUtils.preserveTransformKeyframes)((0, _interactionsUtils.getKeyframes)(animConfig.effect, animConfig.type, animConfig.direction), baseline);
382 + var keyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, animConfig.type, animConfig.direction);
868 383 var options = {
869 384 duration: animConfig.duration / 1000,
870 385 delay: animConfig.delay / 1000,
871 - ease: (0, _interactionsUtils.config)().defaultEasing
386 + easing: _interactionsUtils.config.easing
872 387 };
873 388 var initialKeyframes = {};
874 389 Object.keys(keyframes).forEach(function (key) {
875 390 initialKeyframes[key] = keyframes[key][0];
876 391 });
392 + // WHY - Transition can be set on elements but once it sets it destroys all animations, so we basically put it aside.
393 + var transition = element.style.transition;
394 + element.style.transition = 'none';
877 395 animateFunc(element, initialKeyframes, {
878 396 duration: 0
879 397 }).then(function () {
880 - var animation = animateFunc(element, keyframes, options);
881 - playingInteractionsToStop[id] = animation;
882 - animation.then(function () {
883 - requestAnimationFrame(function () {
884 - (0, _interactionsUtils.resetElementStyles)(element);
885 - });
886 - delete playingInteractionsToStop[id];
398 + animateFunc(element, keyframes, options).then(function () {
399 + if ('out' === animConfig.type) {
400 + var resetValues = {
401 + opacity: 1,
402 + scale: 1,
403 + x: 0,
404 + y: 0
405 + };
406 + var resetKeyframes = {};
407 + Object.keys(keyframes).forEach(function (key) {
408 + resetKeyframes[key] = resetValues[key];
409 + });
410 + element.style.transition = transition;
411 + animateFunc(element, resetKeyframes, {
412 + duration: 0
413 + });
414 + }
887 415 });
888 416 });
889 417 }
890 418 function getInteractionsData() {
@@ -901,19 +429,28 @@
901 429 function findElementByInteractionId(interactionId) {
902 430 return document.querySelector('[data-interaction-id="' + interactionId + '"]');
903 431 }
904 432 function applyInteractionsToElement(element, interactionsData) {
905 - var animateFunc = (0, _interactionsUtils.getAnimateFunction)();
433 + var _window$Motion, _parsedData;
434 + var animateFunc = 'undefined' !== typeof animate ? animate : (_window$Motion = window.Motion) === null || _window$Motion === void 0 ? void 0 : _window$Motion.animate;
906 435 if (!animateFunc) {
907 436 return;
908 437 }
909 - var parsedData = (0, _interactionsUtils.parseInteractionsData)(interactionsData);
910 - if (!parsedData) {
911 - return;
438 + var parsedData;
439 + if ('string' === typeof interactionsData) {
440 + try {
441 + parsedData = JSON.parse(interactionsData);
442 + } catch (error) {
443 + return;
444 + }
445 + } else {
446 + parsedData = interactionsData;
912 447 }
913 - var interactions = Object.values((parsedData === null || parsedData === void 0 ? void 0 : parsedData.items) || []);
448 + var interactions = Object.values((_parsedData = parsedData) === null || _parsedData === void 0 ? void 0 : _parsedData.items);
914 449 interactions.forEach(function (interaction) {
915 - var animConfig = (0, _interactionsUtils.extractAnimationConfig)(interaction);
450 + var _interaction$animatio;
451 + var animationName = 'string' === typeof interaction ? interaction : interaction === null || interaction === void 0 || (_interaction$animatio = interaction.animation) === null || _interaction$animatio === void 0 ? void 0 : _interaction$animatio.animation_id;
452 + var animConfig = animationName && (0, _interactionsUtils.parseAnimationName)(animationName);
916 453 if (animConfig) {
917 454 applyAnimation(element, animConfig, animateFunc);
918 455 }
919 456 });
@@ -921,79 +458,72 @@
921 458 var previousInteractionsData = [];
922 459 function handleInteractionsUpdate() {
923 460 var currentInteractionsData = getInteractionsData();
924 461 var changedItems = currentInteractionsData.filter(function (currentItem) {
925 - var _currentItem$interact, _previousItem$interac;
926 462 var previousItem = previousInteractionsData.find(function (prev) {
927 463 return prev.dataId === currentItem.dataId;
928 464 });
929 - if (!previousItem) {
930 - return true;
931 - }
932 - var currentIds = (((_currentItem$interact = currentItem.interactions) === null || _currentItem$interact === void 0 ? void 0 : _currentItem$interact.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean).sort().join(',');
933 - var prevIds = (((_previousItem$interac = previousItem.interactions) === null || _previousItem$interac === void 0 ? void 0 : _previousItem$interac.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean).sort().join(',');
934 - return currentIds !== prevIds;
465 + return !previousItem || previousItem.interactions !== currentItem.interactions;
935 466 });
936 467 changedItems.forEach(function (item) {
937 - var _previousInteractions, _item$interactions;
468 + var _previousInteractions, _item$interactions, _item$interactions2, _prevInteractions$ite;
938 469 var element = findElementByInteractionId(item.dataId);
939 470 var prevInteractions = (_previousInteractions = previousInteractionsData.find(function (prev) {
940 471 return prev.dataId === item.dataId;
941 472 })) === null || _previousInteractions === void 0 ? void 0 : _previousInteractions.interactions;
942 - if (!element || !((_item$interactions = item.interactions) !== null && _item$interactions !== void 0 && (_item$interactions = _item$interactions.items) !== null && _item$interactions !== void 0 && _item$interactions.length)) {
943 - return;
473 + if (element && ((_item$interactions = item.interactions) === null || _item$interactions === void 0 || (_item$interactions = _item$interactions.items) === null || _item$interactions === void 0 ? void 0 : _item$interactions.length) > 0 && ((_item$interactions2 = item.interactions) === null || _item$interactions2 === void 0 || (_item$interactions2 = _item$interactions2.items) === null || _item$interactions2 === void 0 ? void 0 : _item$interactions2.length) === (prevInteractions === null || prevInteractions === void 0 || (_prevInteractions$ite = prevInteractions.items) === null || _prevInteractions$ite === void 0 ? void 0 : _prevInteractions$ite.length)) {
474 + var interactionsToApply = _objectSpread(_objectSpread({}, item.interactions), {}, {
475 + items: (0, _toConsumableArray2.default)(item.interactions.items).filter(function (interaction, index) {
476 + var _prevInteractions$ite2;
477 + return (prevInteractions === null || prevInteractions === void 0 || (_prevInteractions$ite2 = prevInteractions.items[index]) === null || _prevInteractions$ite2 === void 0 || (_prevInteractions$ite2 = _prevInteractions$ite2.animation) === null || _prevInteractions$ite2 === void 0 ? void 0 : _prevInteractions$ite2.animation_id) !== interaction.animation.animation_id;
478 + })
479 + });
480 + applyInteractionsToElement(element, interactionsToApply);
944 481 }
945 - var prevIds = new Set(((prevInteractions === null || prevInteractions === void 0 ? void 0 : prevInteractions.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean));
946 - var changedInteractions = item.interactions.items.filter(function (interaction) {
947 - var id = (0, _interactionsUtils.extractInteractionId)(interaction);
948 - return !id || !prevIds.has(id);
949 - });
950 - if (changedInteractions.length > 0) {
951 - applyInteractionsToElement(element, _objectSpread(_objectSpread({}, item.interactions), {}, {
952 - items: changedInteractions
953 - }));
954 - }
955 482 });
956 483 previousInteractionsData = currentInteractionsData;
957 484 }
958 485 function initEditorInteractionsHandler() {
959 - (0, _interactionsUtils.waitForAnimateFunction)(function () {
960 - var head = document.head;
961 - var scriptTag = null;
962 - var observer = null;
963 - function setupObserver(tag) {
964 - if (observer) {
965 - observer.disconnect();
966 - }
967 - observer = new MutationObserver(function () {
968 - handleInteractionsUpdate();
969 - });
970 - observer.observe(tag, {
971 - childList: true,
972 - characterData: true,
973 - subtree: true
974 - });
486 + var _window$Motion2;
487 + if ('undefined' === typeof animate && !((_window$Motion2 = window.Motion) !== null && _window$Motion2 !== void 0 && _window$Motion2.animate)) {
488 + setTimeout(initEditorInteractionsHandler, 100);
489 + return;
490 + }
491 + var head = document.head;
492 + var scriptTag = null;
493 + var observer = null;
494 + function setupObserver(tag) {
495 + if (observer) {
496 + observer.disconnect();
497 + }
498 + observer = new MutationObserver(function () {
975 499 handleInteractionsUpdate();
976 - registerWindowEvents();
977 - }
978 - var headObserver = new MutationObserver(function () {
979 - var foundScriptTag = document.querySelector('script[data-e-interactions="true"]');
980 - if (foundScriptTag && foundScriptTag !== scriptTag) {
981 - scriptTag = foundScriptTag;
982 - setupObserver(scriptTag);
983 - headObserver.disconnect();
984 - }
985 500 });
986 - headObserver.observe(head, {
501 + observer.observe(tag, {
987 502 childList: true,
503 + characterData: true,
988 504 subtree: true
989 505 });
990 - scriptTag = document.querySelector('script[data-e-interactions="true"]');
991 - if (scriptTag) {
506 + handleInteractionsUpdate();
507 + registerWindowEvents();
508 + }
509 + var headObserver = new MutationObserver(function () {
510 + var foundScriptTag = document.querySelector('script[data-e-interactions="true"]');
511 + if (foundScriptTag && foundScriptTag !== scriptTag) {
512 + scriptTag = foundScriptTag;
992 513 setupObserver(scriptTag);
993 514 headObserver.disconnect();
994 515 }
995 516 });
517 + headObserver.observe(head, {
518 + childList: true,
519 + subtree: true
520 + });
521 + scriptTag = document.querySelector('script[data-e-interactions="true"]');
522 + if (scriptTag) {
523 + setupObserver(scriptTag);
524 + headObserver.disconnect();
525 + }
996 526 }
997 527 function registerWindowEvents() {
998 528 window.top.addEventListener('atomic/play_interactions', handlePlayInteractions);
999 529 }
@@ -999,9 +529,9 @@
999 529 }
1000 530 function handlePlayInteractions(event) {
1001 531 var _event$detail = event.detail,
1002 532 elementId = _event$detail.elementId,
1003 - interactionId = _event$detail.interactionId;
533 + animationId = _event$detail.animationId;
1004 534 var interactionsData = getInteractionsData();
1005 535 var item = interactionsData.find(function (elementItemData) {
1006 536 return elementItemData.dataId === elementId;
1007 537 });
@@ -1008,18 +538,17 @@
1008 538 if (!item) {
1009 539 return;
1010 540 }
1011 541 var element = findElementByInteractionId(elementId);
1012 - if (!element) {
1013 - return;
542 + if (element) {
543 + var interactionsCopy = _objectSpread(_objectSpread({}, item.interactions), {}, {
544 + items: (0, _toConsumableArray2.default)(item.interactions.items)
545 + });
546 + interactionsCopy.items = interactionsCopy.items.filter(function (interactionItem) {
547 + return interactionItem.animation.animation_id === animationId;
548 + });
549 + applyInteractionsToElement(element, JSON.stringify(interactionsCopy));
1014 550 }
1015 - var interactionsCopy = _objectSpread(_objectSpread({}, item.interactions), {}, {
1016 - items: item.interactions.items.filter(function (interactionItem) {
1017 - var itemId = (0, _interactionsUtils.extractInteractionId)(interactionItem);
1018 - return itemId === interactionId;
1019 - })
1020 - });
1021 - applyInteractionsToElement(element, interactionsCopy);
1022 551 }
1023 552 if ('loading' === document.readyState) {
1024 553 document.addEventListener('DOMContentLoaded', initEditorInteractionsHandler);
1025 554 } else {