| 1 |
"use strict"; |
| 2 |
(function ($) { |
| 3 |
$(window).on('elementor/frontend/init', function () { |
| 4 |
let KngRotatingAnimationHandler = elementorModules.frontend.handlers.Base.extend({ |
| 5 |
onInit: function onInit() { |
| 6 |
if (this.$element.hasClass('kng-rotating-animation-yes')) { |
| 7 |
this.applyKngRotatingAnimation(); |
| 8 |
} |
| 9 |
}, |
| 10 |
getReadySettings: function getReadySettings() { |
| 11 |
let settings = { |
| 12 |
animation_duration: this.getElementSettings('kng_rotating_animation_duration'), |
| 13 |
animation_delay: this.getElementSettings('kng_rotating_animation_delay') |
| 14 |
}; |
| 15 |
return $.extend({}, settings); |
| 16 |
}, |
| 17 |
onElementChange: function onElementChange() { |
| 18 |
if (this.$element.hasClass('kng-rotating-animation-yes')) { |
| 19 |
if (!this.$element.hasClass('kng-style-rotating-animation-applied')) { |
| 20 |
this.applyKngRotatingAnimation(); |
| 21 |
} |
| 22 |
} |
| 23 |
}, |
| 24 |
applyKngRotatingAnimation: function applyKngRotatingAnimation() { |
| 25 |
let options = this.getReadySettings(); |
| 26 |
let element_ID = this.$element.data('id'); |
| 27 |
$('.kng-style-rotating-animation-' + element_ID).remove(); |
| 28 |
this.$element.addClass('kng-style-rotating-animation-applied'); |
| 29 |
this.$element.before('<style>@keyframes rotating-animation-' + element_ID + ' {0% {transform: rotate(0deg);} 100% {transform: rotate(360deg)}}' + |
| 30 |
'.elementor-element-' + element_ID + '.kng-rotating-animation-yes {animation: rotating-animation-' + element_ID + ' ' + options.animation_duration + 'ms linear infinite; animation-delay: ' + options.animation_delay + 'ms;' + |
| 31 |
'</style>'); |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
elementorFrontend.hooks.addAction('frontend/element_ready/global', function ($scope) { |
| 36 |
elementorFrontend.elementsHandler.addHandler(KngRotatingAnimationHandler, { |
| 37 |
$element: $scope |
| 38 |
}); |
| 39 |
}); |
| 40 |
|
| 41 |
}); |
| 42 |
})(jQuery); |