PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.0.7
Easy Elements for Elementor – Addons & Website Templates v1.0.7
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / assets / js / custom.js

custom.js in Easy Elements for Elementor – Addons & Website Templates 1.0.7, at assets/js/custom.js

302 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 "use strict";
3 function initBackPostSlider($scope) {
4 var $slider = $scope.find('.eel-all-slider');
5 if (!$slider.length) {
6 return;
7 }
8 var loop = $slider.data('loop') === true || $slider.data('loop') === 'true';
9 var autoplay = $slider.data('autoplay') === true || $slider.data('autoplay') === 'true';
10 var autoplayDelay = parseInt($slider.data('autoplay-delay'), 10) || 3000;
11 var slidesPerView = parseInt($slider.data('slides-per-view'), 10) || 3;
12 var speed = parseInt($slider.data('speed'), 10) || 600;
13 var centeredSlides = $slider.data('centered-slides') === true || $slider.data('centered-slides') === 'true';
14 var freeMode = $slider.data('free-mode') === true || $slider.data('free-mode') === 'true';
15 var spaceBetween = parseInt($slider.data('space-between'), 10) || 0;
16 var slidesPerViewTablet = parseInt($slider.data('slides-per-view-tablet'), 10) || 2;
17 var slidesPerViewMobile = parseInt($slider.data('slides-per-view-mobile'), 10) || 1;
18 var paginationType = $slider.data('pagination') !== 'none' ? $slider.data('pagination') : false;
19 var navigation = $slider.data('navigation') === true || $slider.data('navigation') === 'true';
20 var effect = $slider.data('effect') || 'slide';
21 var cubeShadow = $slider.data('cube-shadow') === true || $slider.data('cube-shadow') === 'true';
22 var coverflowRotate = parseInt($slider.data('coverflow-rotate'), 10) || 50;
23 var coverflowStretch = parseInt($slider.data('coverflow-stretch'), 10) || 0;
24
25 // Find navigation elements within the scope
26 var $nextButton = $scope.find('.swiper-next');
27 var $prevButton = $scope.find('.swiper-prev');
28 var $pagination = $scope.find('.swiper-pagination');
29
30 // Prevent multiple instances and duplicated handlers if Elementor re-runs init
31 if ($slider[0] && $slider[0].swiper) {
32 try { $slider[0].swiper.destroy(true, true); } catch (e) {}
33 }
34 if ($nextButton.length) { $nextButton.off('click.easyStopAuto click.easyFadeNav'); }
35 if ($prevButton.length) { $prevButton.off('click.easyStopAuto click.easyFadeNav'); }
36
37 var hasProgressBar = $pagination.hasClass('swiper-pagination-progressbar');
38
39 var effectOptions = {};
40
41 if (effect === 'cube') {
42 effectOptions = {
43 cubeEffect: {
44 shadow: cubeShadow,
45 slideShadows: cubeShadow,
46 shadowOffset: 20,
47 shadowScale: 0.94,
48 }
49 };
50 } else if (effect === 'coverflow') {
51 effectOptions = {
52 coverflowEffect: {
53 rotate: coverflowRotate,
54 stretch: coverflowStretch,
55 depth: 100,
56 modifier: 1,
57 slideShadows: true,
58 }
59 };
60 } else if (effect === 'flip') {
61 effectOptions = {
62 flipEffect: {
63 slideShadows: true,
64 limitRotation: true,
65 }
66 };
67 } else if (effect === 'cards') {
68 effectOptions = {
69 cardsEffect: {
70 slideShadows: true,
71 rotate: true,
72 perSlideOffset: 8,
73 }
74 };
75 } else if (effect === 'creative') {
76 var creativeStyle = $slider.data('creative-style') || 'default';
77 if (creativeStyle === 'zoom') {
78 effectOptions = {
79 creativeEffect: {
80 limitProgress: true,
81 prev: { scale: 1.1, opacity: 0, translate: [0, 0, 0] },
82 next: { scale: 1.6, opacity: 0, translate: [0, 0, 0] },
83 },
84 };
85 } else {
86 effectOptions = {
87 creativeEffect: {
88 limitProgress: true,
89 prev: { shadow: true, translate: [0, 0, -400] },
90 next: { translate: ['100%', 0, 0] },
91 },
92 };
93 }
94 } else if (effect === 'fade') {
95 effectOptions = {
96 fadeEffect: { crossFade: true }
97 };
98 }
99
100 // Loop handling tuned to avoid double-advance on loop edges
101 var totalSlides = $slider.find('.swiper-slide').length;
102 var isFade = effect === 'fade';
103 var visibleSlides = isFade ? 1 : slidesPerView;
104 var canLoop = totalSlides > visibleSlides;
105 var loopConfig = {};
106 if (loop && (canLoop || isFade)) {
107 loopConfig = {
108 loop: true,
109 loopAdditionalSlides: isFade ? totalSlides : 20,
110 loopedSlides: isFade ? totalSlides : Math.max(Math.ceil(visibleSlides), Math.min(totalSlides, 10))
111 };
112 } else {
113 loopConfig = { loop: false, rewind: !!loop };
114 }
115
116 var swiper = new Swiper($slider[0], {
117 ...loopConfig,
118 speed: speed,
119 effect: effect,
120 normalizeSlideIndex: true,
121 preventInteractionOnTransition: true,
122 simulateTouch: true,
123 touchRatio: 1,
124 grabCursor: true,
125 mousewheel: hasProgressBar ? {
126 enabled: true,
127 sensitivity: 1,
128 thresholdDelta: 50,
129 thresholdTime: 200,
130 releaseOnEdges: true,
131 invert: false,
132 forceToAxis: false,
133 eventsTarget: 'container'
134 } : false,
135 autoplay: autoplay ? {
136 delay: autoplayDelay,
137 disableOnInteraction: isFade ? true : false,
138 } : false,
139 slidesPerView: visibleSlides,
140 spaceBetween: isFade ? 0 : spaceBetween,
141 centeredSlides: isFade ? false : centeredSlides,
142 freeMode: freeMode,
143 pagination: paginationType && $pagination.length ? {
144 el: $pagination[0],
145 clickable: true,
146 type: paginationType,
147 renderBullet: function (index, className) {
148 let num = (index + 1).toString().padStart(2, '0');
149 return `<span class="${className}">${num}</span>`;
150 }
151 } : false,
152
153 // Progress bar for mouse scroll - only when swiper-pagination-progressbar class is present
154 progressbar: hasProgressBar ? {
155 el: '.swiper-progressbar',
156 type: 'progressbar',
157 } : false,
158
159 navigation: (!isFade) && navigation && ($nextButton.length || $prevButton.length) ? {
160 nextEl: $nextButton.length ? $nextButton[0] : null,
161 prevEl: $prevButton.length ? $prevButton[0] : null,
162 } : false,
163 breakpoints: {
164 0: {
165 slidesPerView: isFade ? 1 : slidesPerViewMobile,
166 },
167 768: {
168 slidesPerView: isFade ? 1 : slidesPerViewTablet,
169 },
170 1024: {
171 slidesPerView: isFade ? 1 : slidesPerView,
172 },
173 },
174 ...effectOptions,
175 });
176
177 // Fade: attach custom navigation so Next/Prev work
178 if (isFade && ($nextButton.length || $prevButton.length)) {
179 var isTransitioning = false;
180 swiper.on('transitionStart', function () { isTransitioning = true; });
181 swiper.on('transitionEnd', function () { isTransitioning = false; });
182 if ($nextButton.length) {
183 $nextButton.off('click.easyFadeNav').on('click.easyFadeNav', function (e) {
184 e.preventDefault();
185 e.stopPropagation();
186 if (swiper && swiper.autoplay && swiper.autoplay.stop) { swiper.autoplay.stop(); }
187 if (isTransitioning || (swiper && swiper.animating)) return;
188 swiper.slideNext();
189 });
190 }
191 if ($prevButton.length) {
192 $prevButton.off('click.easyFadeNav').on('click.easyFadeNav', function (e) {
193 e.preventDefault();
194 e.stopPropagation();
195 if (swiper && swiper.autoplay && swiper.autoplay.stop) { swiper.autoplay.stop(); }
196 if (isTransitioning || (swiper && swiper.animating)) return;
197 swiper.slidePrev();
198 });
199 }
200 }
201
202 // Non-fade: if loop+autoplay, stop autoplay on manual nav to avoid double-advance
203 if (!isFade && loop && autoplay) {
204 if ($nextButton.length) {
205 $nextButton.on('click.easyStopAuto', function () {
206 if (swiper && swiper.autoplay && swiper.autoplay.stop) {
207 swiper.autoplay.stop();
208 }
209 });
210 }
211 if ($prevButton.length) {
212 $prevButton.on('click.easyStopAuto', function () {
213 if (swiper && swiper.autoplay && swiper.autoplay.stop) {
214 swiper.autoplay.stop();
215 }
216 });
217 }
218 }
219 }
220
221 function addWidgetTypeToBody($scope) {
222 var widgetType = $scope.data('widget_type');
223 if (widgetType) {
224 var className = 'easy-eel-has-widget-' + widgetType.replace(/[^a-z0-9_-]/gi, '-').toLowerCase();
225 document.body.classList.add(className);
226 }
227 }
228
229 $(window).on('elementor/frontend/init', function () {
230
231 function checkStickySection() {
232 const stickySection = document.querySelector('.eel-sticky-section');
233 if (stickySection) {
234 document.body.classList.add('sticky-enabled-overlap');
235 } else {
236 document.body.classList.remove('sticky-enabled-overlap');
237 }
238 }
239
240 checkStickySection();
241
242 const observer = new MutationObserver(checkStickySection);
243 observer.observe(document.body, { childList: true, subtree: true });
244 });
245
246
247 function initReveal() {
248 const revealElements = document.querySelectorAll(".eel-img-reveal-wrap, .eel-img-advance-wrap");
249
250 const revealAnimate = (el) => {
251 const target = el.querySelector(".eel-reveal-img-main, .eel-advance-img-main");
252 if(target) target.classList.add("el-reveal-animate");
253 };
254
255 const isEditor = window.elementorFrontend && elementorFrontend.isEditMode && elementorFrontend.isEditMode();
256
257 if(isEditor){
258
259 revealElements.forEach(el => revealAnimate(el));
260 } else {
261
262 const observer = new IntersectionObserver((entries, obs) => {
263 entries.forEach(entry => {
264 if(entry.isIntersecting){
265 revealAnimate(entry.target);
266 obs.unobserve(entry.target);
267 }
268 });
269 }, { threshold: 0.3 });
270
271 revealElements.forEach(el => observer.observe(el));
272 }
273 }
274
275 $(window).on('elementor/frontend/init', function () {
276 elementorFrontend.hooks.addAction('frontend/element_ready/global', initBackPostSlider);
277 elementorFrontend.hooks.addAction('frontend/element_ready/global', addWidgetTypeToBody);
278 elementorFrontend.hooks.addAction('frontend/element_ready/global', initReveal);
279 });
280
281 document.addEventListener('DOMContentLoaded', function () {
282 // Remove motion effects inline styles
283 document.querySelectorAll('[data-settings]').forEach(function (element) {
284 let settings = element.getAttribute('data-settings');
285 if (settings.includes('motion_effects')) {
286 element.removeAttribute('data-settings');
287 }
288 });
289
290 // Remove any animation-related stylesheets
291 document.querySelectorAll('link').forEach(function (link) {
292 if (link.href.includes('animations') || link.href.includes('motion')) {
293 link.parentNode.removeChild(link);
294 }
295 });
296 });
297
298 })(jQuery);
299
300
301
302