(function($) { "use strict"; $(window).on('elementor/frontend/init', function($scope, settings) { var _elementor = typeof elementor != 'undefined' ? elementor : elementorFrontend; // lazy load image var GlobalLazyLoad = function($scope, $) { $.each($scope.find('.cms-lazy'), function(index, item) { const observer = elementorModules.utils.Scroll.scrollObserver({ callback: event => { if (event.isInViewport) { // remove css class $(this).removeClass('lazy-loading').addClass('cms-lazy-loaded'); // add style var duration = $(this).data('duration'); if (typeof duration != 'undefined') { $(this).css({ 'animation-duration': duration + 'ms' }); } } } }); observer.observe(item); }); }; elementorFrontend.hooks.addAction('frontend/element_ready/global', GlobalLazyLoad); /** * Animate * Make animate re-play * * */ var GlobalWidgetAnimateHandler = function($scope, $) { $.each($scope.find('.elementor-invisible'), function(index, item) { const observer = elementorModules.utils.Scroll.scrollObserver({ callback: event => { var animate = $(this), data = animate.data('settings'); if (typeof data['animation'] != 'undefined' || typeof data['_animation'] != 'undefined') { if (event.isInViewport) { $(this).addClass('cms-inview'); // setTimeout(function() { animate.removeClass('elementor-invisible').addClass('animated ' + data['animation']); }, data['animation_delay']); // if(typeof data['_animation'] != 'undefined'){ setTimeout(function() { animate.addClass(data['_animation']); }, data['_animation_delay']); } } else { // Revert /*$(this).removeClass('cms-inview').removeClass('animated').removeClass(data['animation']).addClass('elementor-invisible'); if(typeof data['_animation'] != 'undefined'){ $(this).removeClass(data['_animation']); }*/ } } } }); observer.observe(item); }); }; elementorFrontend.hooks.addAction('frontend/element_ready/global', GlobalWidgetAnimateHandler); }); }(jQuery));