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

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