PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev3
Elementor Website Builder – more than just a page builder v3.35.0-dev3
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 3.35.0-dev3, at assets/js/interactions.js

408 lines 16.9 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-utils.js":
5 /*!***************************************************************!*\
6 !*** ../modules/interactions/assets/js/interactions-utils.js ***!
7 \***************************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11
12
13 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
14 Object.defineProperty(exports, "__esModule", ({
15 value: true
16 }));
17 exports.config = void 0;
18 exports.extractAnimationId = extractAnimationId;
19 exports.extractInteractionId = extractInteractionId;
20 exports.getAnimateFunction = getAnimateFunction;
21 exports.getInViewFunction = getInViewFunction;
22 exports.getKeyframes = getKeyframes;
23 exports.parseAnimationName = parseAnimationName;
24 exports.parseInteractionsData = parseInteractionsData;
25 exports.waitForAnimateFunction = waitForAnimateFunction;
26 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
27 var _window$ElementorInte;
28 var config = exports.config = ((_window$ElementorInte = window.ElementorInteractionsConfig) === null || _window$ElementorInte === void 0 ? void 0 : _window$ElementorInte.constants) || {
29 defaultDuration: 300,
30 defaultDelay: 0,
31 slideDistance: 100,
32 scaleStart: 0,
33 ease: 'easeIn'
34 };
35 function getKeyframes(effect, type, direction) {
36 var isIn = 'in' === type;
37 var keyframes = {};
38 if ('fade' === effect) {
39 keyframes.opacity = isIn ? [0, 1] : [1, 0];
40 }
41 if ('scale' === effect) {
42 keyframes.scale = isIn ? [config.scaleStart, 1] : [1, config.scaleStart];
43 }
44 if (direction) {
45 var distance = config.slideDistance;
46 var movement = {
47 left: {
48 x: isIn ? [-distance, 0] : [0, -distance]
49 },
50 right: {
51 x: isIn ? [distance, 0] : [0, distance]
52 },
53 top: {
54 y: isIn ? [-distance, 0] : [0, -distance]
55 },
56 bottom: {
57 y: isIn ? [distance, 0] : [0, distance]
58 }
59 };
60 Object.assign(keyframes, movement[direction]);
61 }
62 return keyframes;
63 }
64 function parseAnimationName(name) {
65 var _name$split = name.split('-'),
66 _name$split2 = (0, _slicedToArray2.default)(_name$split, 6),
67 trigger = _name$split2[0],
68 effect = _name$split2[1],
69 type = _name$split2[2],
70 direction = _name$split2[3],
71 duration = _name$split2[4],
72 delay = _name$split2[5];
73 return {
74 trigger: trigger,
75 effect: effect,
76 type: type,
77 direction: direction || null,
78 duration: duration ? parseInt(duration, 10) : config.defaultDuration,
79 delay: delay ? parseInt(delay, 10) : config.defaultDelay
80 };
81 }
82 function extractAnimationId(interaction) {
83 var _interaction$animatio;
84 if ('string' === typeof interaction) {
85 return interaction;
86 }
87 if ('interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value) {
88 var _interaction$value = interaction.value,
89 trigger = _interaction$value.trigger,
90 animation = _interaction$value.animation;
91 if ('animation-preset-props' === (animation === null || animation === void 0 ? void 0 : animation.$$type) && animation !== null && animation !== void 0 && animation.value) {
92 var _timingConfig$value$d, _timingConfig$value, _timingConfig$value$d2, _timingConfig$value2;
93 var _animation$value = animation.value,
94 effect = _animation$value.effect,
95 type = _animation$value.type,
96 direction = _animation$value.direction,
97 timingConfig = _animation$value.timing_config;
98 var triggerVal = (trigger === null || trigger === void 0 ? void 0 : trigger.value) || 'load';
99 var effectVal = (effect === null || effect === void 0 ? void 0 : effect.value) || 'fade';
100 var typeVal = (type === null || type === void 0 ? void 0 : type.value) || 'in';
101 var directionVal = (direction === null || direction === void 0 ? void 0 : direction.value) || '';
102 var duration = (_timingConfig$value$d = timingConfig === null || timingConfig === void 0 || (_timingConfig$value = timingConfig.value) === null || _timingConfig$value === void 0 || (_timingConfig$value = _timingConfig$value.duration) === null || _timingConfig$value === void 0 ? void 0 : _timingConfig$value.value) !== null && _timingConfig$value$d !== void 0 ? _timingConfig$value$d : 300;
103 var delay = (_timingConfig$value$d2 = timingConfig === null || timingConfig === void 0 || (_timingConfig$value2 = timingConfig.value) === null || _timingConfig$value2 === void 0 || (_timingConfig$value2 = _timingConfig$value2.delay) === null || _timingConfig$value2 === void 0 ? void 0 : _timingConfig$value2.value) !== null && _timingConfig$value$d2 !== void 0 ? _timingConfig$value$d2 : 0;
104 return "".concat(triggerVal, "-").concat(effectVal, "-").concat(typeVal, "-").concat(directionVal, "-").concat(duration, "-").concat(delay);
105 }
106 }
107 if (interaction !== null && interaction !== void 0 && (_interaction$animatio = interaction.animation) !== null && _interaction$animatio !== void 0 && _interaction$animatio.animation_id) {
108 return interaction.animation.animation_id;
109 }
110 return null;
111 }
112 function extractInteractionId(interaction) {
113 if ('interaction-item' === (interaction === null || interaction === void 0 ? void 0 : interaction.$$type) && interaction !== null && interaction !== void 0 && interaction.value) {
114 var _interaction$value$in;
115 return ((_interaction$value$in = interaction.value.interaction_id) === null || _interaction$value$in === void 0 ? void 0 : _interaction$value$in.value) || null;
116 }
117 return null;
118 }
119 function getAnimateFunction() {
120 var _window$Motion;
121 return 'undefined' !== typeof animate ? animate : (_window$Motion = window.Motion) === null || _window$Motion === void 0 ? void 0 : _window$Motion.animate;
122 }
123 function getInViewFunction() {
124 var _window$Motion2;
125 return 'undefined' !== typeof inView ? inView : (_window$Motion2 = window.Motion) === null || _window$Motion2 === void 0 ? void 0 : _window$Motion2.inView;
126 }
127 function waitForAnimateFunction(callback) {
128 var maxAttempts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
129 if (getAnimateFunction()) {
130 callback();
131 return;
132 }
133 if (maxAttempts > 0) {
134 setTimeout(function () {
135 return waitForAnimateFunction(callback, maxAttempts - 1);
136 }, 100);
137 }
138 }
139 function parseInteractionsData(data) {
140 if ('string' === typeof data) {
141 try {
142 return JSON.parse(data);
143 } catch (_unused) {
144 return null;
145 }
146 }
147 return data;
148 }
149
150 /***/ }),
151
152 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
153 /*!******************************************************************!*\
154 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
155 \******************************************************************/
156 /***/ ((module) => {
157
158 function _arrayLikeToArray(r, a) {
159 (null == a || a > r.length) && (a = r.length);
160 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
161 return n;
162 }
163 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
164
165 /***/ }),
166
167 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
168 /*!****************************************************************!*\
169 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
170 \****************************************************************/
171 /***/ ((module) => {
172
173 function _arrayWithHoles(r) {
174 if (Array.isArray(r)) return r;
175 }
176 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
177
178 /***/ }),
179
180 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
181 /*!***********************************************************************!*\
182 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
183 \***********************************************************************/
184 /***/ ((module) => {
185
186 function _interopRequireDefault(e) {
187 return e && e.__esModule ? e : {
188 "default": e
189 };
190 }
191 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
192
193 /***/ }),
194
195 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
196 /*!**********************************************************************!*\
197 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
198 \**********************************************************************/
199 /***/ ((module) => {
200
201 function _iterableToArrayLimit(r, l) {
202 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
203 if (null != t) {
204 var e,
205 n,
206 i,
207 u,
208 a = [],
209 f = !0,
210 o = !1;
211 try {
212 if (i = (t = t.call(r)).next, 0 === l) {
213 if (Object(t) !== t) return;
214 f = !1;
215 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
216 } catch (r) {
217 o = !0, n = r;
218 } finally {
219 try {
220 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
221 } finally {
222 if (o) throw n;
223 }
224 }
225 return a;
226 }
227 }
228 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
229
230 /***/ }),
231
232 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
233 /*!*****************************************************************!*\
234 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
235 \*****************************************************************/
236 /***/ ((module) => {
237
238 function _nonIterableRest() {
239 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
240 }
241 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
242
243 /***/ }),
244
245 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
246 /*!***************************************************************!*\
247 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
248 \***************************************************************/
249 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
250
251 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
252 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
253 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
254 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
255 function _slicedToArray(r, e) {
256 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
257 }
258 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
259
260 /***/ }),
261
262 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
263 /*!****************************************************************************!*\
264 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
265 \****************************************************************************/
266 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
267
268 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
269 function _unsupportedIterableToArray(r, a) {
270 if (r) {
271 if ("string" == typeof r) return arrayLikeToArray(r, a);
272 var t = {}.toString.call(r).slice(8, -1);
273 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;
274 }
275 }
276 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
277
278 /***/ })
279
280 /******/ });
281 /************************************************************************/
282 /******/ // The module cache
283 /******/ var __webpack_module_cache__ = {};
284 /******/
285 /******/ // The require function
286 /******/ function __webpack_require__(moduleId) {
287 /******/ // Check if module is in cache
288 /******/ var cachedModule = __webpack_module_cache__[moduleId];
289 /******/ if (cachedModule !== undefined) {
290 /******/ return cachedModule.exports;
291 /******/ }
292 /******/ // Create a new module (and put it into the cache)
293 /******/ var module = __webpack_module_cache__[moduleId] = {
294 /******/ // no module.id needed
295 /******/ // no module.loaded needed
296 /******/ exports: {}
297 /******/ };
298 /******/
299 /******/ // Execute the module function
300 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
301 /******/
302 /******/ // Return the exports of the module
303 /******/ return module.exports;
304 /******/ }
305 /******/
306 /************************************************************************/
307 var __webpack_exports__ = {};
308 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
309 (() => {
310 "use strict";
311 /*!*********************************************************!*\
312 !*** ../modules/interactions/assets/js/interactions.js ***!
313 \*********************************************************/
314
315
316 var _interactionsUtils = __webpack_require__(/*! ./interactions-utils.js */ "../modules/interactions/assets/js/interactions-utils.js");
317 function scrollOutAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc) {
318 var viewOptions = {
319 amount: 0.85,
320 root: null
321 };
322 var resetKeyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, 'in', animConfig.direction);
323 animateFunc(element, resetKeyframes, {
324 duration: 0
325 });
326 var stop = inViewFunc(element, function () {
327 return function () {
328 animateFunc(element, keyframes, options).then(function () {
329 element.style.transition = transition;
330 });
331 if (false === animConfig.replay) {
332 stop();
333 }
334 };
335 }, viewOptions);
336 }
337 function scrollInAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc) {
338 var viewOptions = {
339 amount: 0,
340 root: null
341 };
342 var stop = inViewFunc(element, function () {
343 animateFunc(element, keyframes, options).then(function () {
344 element.style.transition = transition;
345 });
346 if (false === animConfig.replay) {
347 stop();
348 }
349 }, viewOptions);
350 }
351 function defaultAnimation(element, transition, keyframes, options, animateFunc) {
352 animateFunc(element, keyframes, options).then(function () {
353 element.style.transition = transition;
354 });
355 }
356 function applyAnimation(element, animConfig, animateFunc, inViewFunc) {
357 var keyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, animConfig.type, animConfig.direction);
358 var options = {
359 duration: animConfig.duration / 1000,
360 delay: animConfig.delay / 1000,
361 ease: _interactionsUtils.config.ease
362 };
363
364 // WHY - Transition can be set on elements but once it sets it destroys all animations, so we basically put it aside.
365 var transition = element.style.transition;
366 element.style.transition = 'none';
367 if ('scrollOut' === animConfig.trigger) {
368 scrollOutAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc);
369 } else if ('scrollIn' === animConfig.trigger) {
370 scrollInAnimation(element, transition, animConfig, keyframes, options, animateFunc, inViewFunc);
371 } else {
372 defaultAnimation(element, transition, keyframes, options, animateFunc);
373 }
374 }
375 function initInteractions() {
376 (0, _interactionsUtils.waitForAnimateFunction)(function () {
377 var animateFunc = (0, _interactionsUtils.getAnimateFunction)();
378 var inViewFunc = (0, _interactionsUtils.getInViewFunction)();
379 if (!inViewFunc || !animateFunc) {
380 return;
381 }
382 var elements = document.querySelectorAll('[data-interactions]');
383 elements.forEach(function (element) {
384 var interactionsData = element.getAttribute('data-interactions');
385 var parsedData = (0, _interactionsUtils.parseInteractionsData)(interactionsData);
386 if (!parsedData || !Array.isArray(parsedData)) {
387 return;
388 }
389 parsedData.forEach(function (interaction) {
390 var animationName = (0, _interactionsUtils.extractAnimationId)(interaction);
391 var animConfig = animationName && (0, _interactionsUtils.parseAnimationName)(animationName);
392 if (animConfig) {
393 applyAnimation(element, animConfig, animateFunc, inViewFunc);
394 }
395 });
396 });
397 });
398 }
399 if ('loading' === document.readyState) {
400 document.addEventListener('DOMContentLoaded', initInteractions);
401 } else {
402 initInteractions();
403 }
404 })();
405
406 /******/ })()
407 ;
408 //# sourceMappingURL=interactions.js.map