| 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/defineProperty.js": |
| 181 |
/*!****************************************************************!*\ |
| 182 |
!*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***! |
| 183 |
\****************************************************************/ |
| 184 |
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 185 |
|
| 186 |
var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js"); |
| 187 |
function _defineProperty(e, r, t) { |
| 188 |
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { |
| 189 |
value: t, |
| 190 |
enumerable: !0, |
| 191 |
configurable: !0, |
| 192 |
writable: !0 |
| 193 |
}) : e[r] = t, e; |
| 194 |
} |
| 195 |
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 196 |
|
| 197 |
/***/ }), |
| 198 |
|
| 199 |
/***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js": |
| 200 |
/*!***********************************************************************!*\ |
| 201 |
!*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***! |
| 202 |
\***********************************************************************/ |
| 203 |
/***/ ((module) => { |
| 204 |
|
| 205 |
function _interopRequireDefault(e) { |
| 206 |
return e && e.__esModule ? e : { |
| 207 |
"default": e |
| 208 |
}; |
| 209 |
} |
| 210 |
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 211 |
|
| 212 |
/***/ }), |
| 213 |
|
| 214 |
/***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js": |
| 215 |
/*!**********************************************************************!*\ |
| 216 |
!*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***! |
| 217 |
\**********************************************************************/ |
| 218 |
/***/ ((module) => { |
| 219 |
|
| 220 |
function _iterableToArrayLimit(r, l) { |
| 221 |
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; |
| 222 |
if (null != t) { |
| 223 |
var e, |
| 224 |
n, |
| 225 |
i, |
| 226 |
u, |
| 227 |
a = [], |
| 228 |
f = !0, |
| 229 |
o = !1; |
| 230 |
try { |
| 231 |
if (i = (t = t.call(r)).next, 0 === l) { |
| 232 |
if (Object(t) !== t) return; |
| 233 |
f = !1; |
| 234 |
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); |
| 235 |
} catch (r) { |
| 236 |
o = !0, n = r; |
| 237 |
} finally { |
| 238 |
try { |
| 239 |
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; |
| 240 |
} finally { |
| 241 |
if (o) throw n; |
| 242 |
} |
| 243 |
} |
| 244 |
return a; |
| 245 |
} |
| 246 |
} |
| 247 |
module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 248 |
|
| 249 |
/***/ }), |
| 250 |
|
| 251 |
/***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js": |
| 252 |
/*!*****************************************************************!*\ |
| 253 |
!*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***! |
| 254 |
\*****************************************************************/ |
| 255 |
/***/ ((module) => { |
| 256 |
|
| 257 |
function _nonIterableRest() { |
| 258 |
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
| 259 |
} |
| 260 |
module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 261 |
|
| 262 |
/***/ }), |
| 263 |
|
| 264 |
/***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js": |
| 265 |
/*!***************************************************************!*\ |
| 266 |
!*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***! |
| 267 |
\***************************************************************/ |
| 268 |
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 269 |
|
| 270 |
var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js"); |
| 271 |
var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"); |
| 272 |
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"); |
| 273 |
var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js"); |
| 274 |
function _slicedToArray(r, e) { |
| 275 |
return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest(); |
| 276 |
} |
| 277 |
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 278 |
|
| 279 |
/***/ }), |
| 280 |
|
| 281 |
/***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js": |
| 282 |
/*!*************************************************************!*\ |
| 283 |
!*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***! |
| 284 |
\*************************************************************/ |
| 285 |
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 286 |
|
| 287 |
var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]); |
| 288 |
function toPrimitive(t, r) { |
| 289 |
if ("object" != _typeof(t) || !t) return t; |
| 290 |
var e = t[Symbol.toPrimitive]; |
| 291 |
if (void 0 !== e) { |
| 292 |
var i = e.call(t, r || "default"); |
| 293 |
if ("object" != _typeof(i)) return i; |
| 294 |
throw new TypeError("@@toPrimitive must return a primitive value."); |
| 295 |
} |
| 296 |
return ("string" === r ? String : Number)(t); |
| 297 |
} |
| 298 |
module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 299 |
|
| 300 |
/***/ }), |
| 301 |
|
| 302 |
/***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js": |
| 303 |
/*!***************************************************************!*\ |
| 304 |
!*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***! |
| 305 |
\***************************************************************/ |
| 306 |
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 307 |
|
| 308 |
var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]); |
| 309 |
var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js"); |
| 310 |
function toPropertyKey(t) { |
| 311 |
var i = toPrimitive(t, "string"); |
| 312 |
return "symbol" == _typeof(i) ? i : i + ""; |
| 313 |
} |
| 314 |
module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 315 |
|
| 316 |
/***/ }), |
| 317 |
|
| 318 |
/***/ "../node_modules/@babel/runtime/helpers/typeof.js": |
| 319 |
/*!********************************************************!*\ |
| 320 |
!*** ../node_modules/@babel/runtime/helpers/typeof.js ***! |
| 321 |
\********************************************************/ |
| 322 |
/***/ ((module) => { |
| 323 |
|
| 324 |
function _typeof(o) { |
| 325 |
"@babel/helpers - typeof"; |
| 326 |
|
| 327 |
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { |
| 328 |
return typeof o; |
| 329 |
} : function (o) { |
| 330 |
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; |
| 331 |
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); |
| 332 |
} |
| 333 |
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 334 |
|
| 335 |
/***/ }), |
| 336 |
|
| 337 |
/***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js": |
| 338 |
/*!****************************************************************************!*\ |
| 339 |
!*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***! |
| 340 |
\****************************************************************************/ |
| 341 |
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
| 342 |
|
| 343 |
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js"); |
| 344 |
function _unsupportedIterableToArray(r, a) { |
| 345 |
if (r) { |
| 346 |
if ("string" == typeof r) return arrayLikeToArray(r, a); |
| 347 |
var t = {}.toString.call(r).slice(8, -1); |
| 348 |
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; |
| 349 |
} |
| 350 |
} |
| 351 |
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; |
| 352 |
|
| 353 |
/***/ }) |
| 354 |
|
| 355 |
/******/ }); |
| 356 |
/************************************************************************/ |
| 357 |
/******/ // The module cache |
| 358 |
/******/ var __webpack_module_cache__ = {}; |
| 359 |
/******/ |
| 360 |
/******/ // The require function |
| 361 |
/******/ function __webpack_require__(moduleId) { |
| 362 |
/******/ // Check if module is in cache |
| 363 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 364 |
/******/ if (cachedModule !== undefined) { |
| 365 |
/******/ return cachedModule.exports; |
| 366 |
/******/ } |
| 367 |
/******/ // Create a new module (and put it into the cache) |
| 368 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 369 |
/******/ // no module.id needed |
| 370 |
/******/ // no module.loaded needed |
| 371 |
/******/ exports: {} |
| 372 |
/******/ }; |
| 373 |
/******/ |
| 374 |
/******/ // Execute the module function |
| 375 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 376 |
/******/ |
| 377 |
/******/ // Return the exports of the module |
| 378 |
/******/ return module.exports; |
| 379 |
/******/ } |
| 380 |
/******/ |
| 381 |
/************************************************************************/ |
| 382 |
var __webpack_exports__ = {}; |
| 383 |
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode. |
| 384 |
(() => { |
| 385 |
"use strict"; |
| 386 |
/*!****************************************************************!*\ |
| 387 |
!*** ../modules/interactions/assets/js/editor-interactions.js ***! |
| 388 |
\****************************************************************/ |
| 389 |
|
| 390 |
|
| 391 |
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js"); |
| 392 |
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js")); |
| 393 |
var _interactionsUtils = __webpack_require__(/*! ./interactions-utils.js */ "../modules/interactions/assets/js/interactions-utils.js"); |
| 394 |
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; } |
| 395 |
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; } |
| 396 |
function applyAnimation(element, animConfig, animateFunc) { |
| 397 |
var keyframes = (0, _interactionsUtils.getKeyframes)(animConfig.effect, animConfig.type, animConfig.direction); |
| 398 |
var options = { |
| 399 |
duration: animConfig.duration / 1000, |
| 400 |
delay: animConfig.delay / 1000, |
| 401 |
ease: _interactionsUtils.config.ease |
| 402 |
}; |
| 403 |
var initialKeyframes = {}; |
| 404 |
Object.keys(keyframes).forEach(function (key) { |
| 405 |
initialKeyframes[key] = keyframes[key][0]; |
| 406 |
}); |
| 407 |
// WHY - Transition can be set on elements but once it sets it destroys all animations, so we basically put it aside. |
| 408 |
var transition = element.style.transition; |
| 409 |
element.style.transition = 'none'; |
| 410 |
animateFunc(element, initialKeyframes, { |
| 411 |
duration: 0 |
| 412 |
}).then(function () { |
| 413 |
animateFunc(element, keyframes, options).then(function () { |
| 414 |
if ('out' === animConfig.type) { |
| 415 |
var resetValues = { |
| 416 |
opacity: 1, |
| 417 |
scale: 1, |
| 418 |
x: 0, |
| 419 |
y: 0 |
| 420 |
}; |
| 421 |
var resetKeyframes = {}; |
| 422 |
Object.keys(keyframes).forEach(function (key) { |
| 423 |
resetKeyframes[key] = resetValues[key]; |
| 424 |
}); |
| 425 |
element.style.transition = transition; |
| 426 |
animateFunc(element, resetKeyframes, { |
| 427 |
duration: 0 |
| 428 |
}); |
| 429 |
} |
| 430 |
}); |
| 431 |
}); |
| 432 |
} |
| 433 |
function getInteractionsData() { |
| 434 |
var scriptTag = document.querySelector('script[data-e-interactions="true"]'); |
| 435 |
if (!scriptTag) { |
| 436 |
return []; |
| 437 |
} |
| 438 |
try { |
| 439 |
return JSON.parse(scriptTag.textContent || '[]'); |
| 440 |
} catch (_unused) { |
| 441 |
return []; |
| 442 |
} |
| 443 |
} |
| 444 |
function findElementByInteractionId(interactionId) { |
| 445 |
return document.querySelector('[data-interaction-id="' + interactionId + '"]'); |
| 446 |
} |
| 447 |
function applyInteractionsToElement(element, interactionsData) { |
| 448 |
var animateFunc = (0, _interactionsUtils.getAnimateFunction)(); |
| 449 |
if (!animateFunc) { |
| 450 |
return; |
| 451 |
} |
| 452 |
var parsedData = (0, _interactionsUtils.parseInteractionsData)(interactionsData); |
| 453 |
if (!parsedData) { |
| 454 |
return; |
| 455 |
} |
| 456 |
var interactions = Object.values((parsedData === null || parsedData === void 0 ? void 0 : parsedData.items) || []); |
| 457 |
interactions.forEach(function (interaction) { |
| 458 |
var animationName = (0, _interactionsUtils.extractAnimationId)(interaction); |
| 459 |
var animConfig = animationName && (0, _interactionsUtils.parseAnimationName)(animationName); |
| 460 |
if (animConfig) { |
| 461 |
applyAnimation(element, animConfig, animateFunc); |
| 462 |
} |
| 463 |
}); |
| 464 |
} |
| 465 |
var previousInteractionsData = []; |
| 466 |
function handleInteractionsUpdate() { |
| 467 |
var currentInteractionsData = getInteractionsData(); |
| 468 |
var changedItems = currentInteractionsData.filter(function (currentItem) { |
| 469 |
var _currentItem$interact, _previousItem$interac; |
| 470 |
var previousItem = previousInteractionsData.find(function (prev) { |
| 471 |
return prev.dataId === currentItem.dataId; |
| 472 |
}); |
| 473 |
if (!previousItem) { |
| 474 |
return true; |
| 475 |
} |
| 476 |
var currentIds = (((_currentItem$interact = currentItem.interactions) === null || _currentItem$interact === void 0 ? void 0 : _currentItem$interact.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean).sort().join(','); |
| 477 |
var prevIds = (((_previousItem$interac = previousItem.interactions) === null || _previousItem$interac === void 0 ? void 0 : _previousItem$interac.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean).sort().join(','); |
| 478 |
return currentIds !== prevIds; |
| 479 |
}); |
| 480 |
changedItems.forEach(function (item) { |
| 481 |
var _previousInteractions, _item$interactions; |
| 482 |
var element = findElementByInteractionId(item.dataId); |
| 483 |
var prevInteractions = (_previousInteractions = previousInteractionsData.find(function (prev) { |
| 484 |
return prev.dataId === item.dataId; |
| 485 |
})) === null || _previousInteractions === void 0 ? void 0 : _previousInteractions.interactions; |
| 486 |
if (!element || !((_item$interactions = item.interactions) !== null && _item$interactions !== void 0 && (_item$interactions = _item$interactions.items) !== null && _item$interactions !== void 0 && _item$interactions.length)) { |
| 487 |
return; |
| 488 |
} |
| 489 |
var prevIds = new Set(((prevInteractions === null || prevInteractions === void 0 ? void 0 : prevInteractions.items) || []).map(_interactionsUtils.extractInteractionId).filter(Boolean)); |
| 490 |
var changedInteractions = item.interactions.items.filter(function (interaction) { |
| 491 |
var id = (0, _interactionsUtils.extractInteractionId)(interaction); |
| 492 |
return !id || !prevIds.has(id); |
| 493 |
}); |
| 494 |
if (changedInteractions.length > 0) { |
| 495 |
applyInteractionsToElement(element, _objectSpread(_objectSpread({}, item.interactions), {}, { |
| 496 |
items: changedInteractions |
| 497 |
})); |
| 498 |
} |
| 499 |
}); |
| 500 |
previousInteractionsData = currentInteractionsData; |
| 501 |
} |
| 502 |
function initEditorInteractionsHandler() { |
| 503 |
(0, _interactionsUtils.waitForAnimateFunction)(function () { |
| 504 |
var head = document.head; |
| 505 |
var scriptTag = null; |
| 506 |
var observer = null; |
| 507 |
function setupObserver(tag) { |
| 508 |
if (observer) { |
| 509 |
observer.disconnect(); |
| 510 |
} |
| 511 |
observer = new MutationObserver(function () { |
| 512 |
handleInteractionsUpdate(); |
| 513 |
}); |
| 514 |
observer.observe(tag, { |
| 515 |
childList: true, |
| 516 |
characterData: true, |
| 517 |
subtree: true |
| 518 |
}); |
| 519 |
handleInteractionsUpdate(); |
| 520 |
registerWindowEvents(); |
| 521 |
} |
| 522 |
var headObserver = new MutationObserver(function () { |
| 523 |
var foundScriptTag = document.querySelector('script[data-e-interactions="true"]'); |
| 524 |
if (foundScriptTag && foundScriptTag !== scriptTag) { |
| 525 |
scriptTag = foundScriptTag; |
| 526 |
setupObserver(scriptTag); |
| 527 |
headObserver.disconnect(); |
| 528 |
} |
| 529 |
}); |
| 530 |
headObserver.observe(head, { |
| 531 |
childList: true, |
| 532 |
subtree: true |
| 533 |
}); |
| 534 |
scriptTag = document.querySelector('script[data-e-interactions="true"]'); |
| 535 |
if (scriptTag) { |
| 536 |
setupObserver(scriptTag); |
| 537 |
headObserver.disconnect(); |
| 538 |
} |
| 539 |
}); |
| 540 |
} |
| 541 |
function registerWindowEvents() { |
| 542 |
window.top.addEventListener('atomic/play_interactions', handlePlayInteractions); |
| 543 |
} |
| 544 |
function handlePlayInteractions(event) { |
| 545 |
var _event$detail = event.detail, |
| 546 |
elementId = _event$detail.elementId, |
| 547 |
interactionId = _event$detail.interactionId; |
| 548 |
var interactionsData = getInteractionsData(); |
| 549 |
var item = interactionsData.find(function (elementItemData) { |
| 550 |
return elementItemData.dataId === elementId; |
| 551 |
}); |
| 552 |
if (!item) { |
| 553 |
return; |
| 554 |
} |
| 555 |
var element = findElementByInteractionId(elementId); |
| 556 |
if (!element) { |
| 557 |
return; |
| 558 |
} |
| 559 |
var interactionsCopy = _objectSpread(_objectSpread({}, item.interactions), {}, { |
| 560 |
items: item.interactions.items.filter(function (interactionItem) { |
| 561 |
var itemId = (0, _interactionsUtils.extractInteractionId)(interactionItem); |
| 562 |
return itemId === interactionId; |
| 563 |
}) |
| 564 |
}); |
| 565 |
applyInteractionsToElement(element, interactionsCopy); |
| 566 |
} |
| 567 |
if ('loading' === document.readyState) { |
| 568 |
document.addEventListener('DOMContentLoaded', initEditorInteractionsHandler); |
| 569 |
} else { |
| 570 |
initEditorInteractionsHandler(); |
| 571 |
} |
| 572 |
})(); |
| 573 |
|
| 574 |
/******/ })() |
| 575 |
; |
| 576 |
//# sourceMappingURL=editor-interactions.js.map |