PluginProbe ʕ •ᴥ•ʔ
Premium Addons for Elementor – Powerful Elementor Templates & Widgets / 4.10.78
Premium Addons for Elementor – Powerful Elementor Templates & Widgets v4.10.78
4.11.83 4.11.82 4.11.80 4.11.81 4.11.79 4.11.78 4.11.77 4.11.76 4.11.75 3.20.5 4.11.69 3.20.6 4.11.7 3.20.7 4.11.70 3.20.8 4.11.71 3.20.9 4.11.72 3.21.1 4.11.73 3.21.2 4.11.74 3.21.3 4.11.8 3.21.4 4.11.9 3.21.5 4.2.0 3.21.6 4.2.1 3.3.0 4.2.2 3.3.1 4.2.3 3.3.2 4.2.4 3.3.3 4.2.5 3.3.4 4.2.6 3.3.5 4.2.7 3.3.6 4.2.8 3.3.7 4.2.9 3.3.8 4.3.0 3.3.9 4.3.1 3.4.0 4.3.2 3.4.1 4.3.3 3.4.2 4.3.4 3.4.3 4.3.5 3.4.4 4.3.6 3.4.5 4.3.7 3.4.6 4.3.8 3.4.7 4.3.9 3.4.8 4.4.0 3.4.9 4.4.1 3.5.0 4.4.2 3.5.1 4.4.3 3.5.2 4.4.4 3.5.3 4.4.5 3.5.4 4.4.6 3.5.5 4.4.7 3.5.6 4.4.8 3.5.7 4.4.9 3.5.8 4.5.0 3.5.9 4.5.1 3.6.0 4.5.2 3.6.1 4.5.3 3.6.2 4.5.4 3.6.3 4.5.5 3.6.4 4.5.6 3.6.5 4.5.7 3.6.6 4.5.8 3.6.7 4.5.9 3.6.8 4.6.0 3.6.9 4.6.1 3.7.0 4.7.0 3.7.1 4.7.1 3.7.2 4.7.2 3.7.3 4.7.3 3.7.4 4.7.4 3.7.5 4.7.5 3.7.6 4.7.6 3.7.7 4.7.7 3.7.8 4.7.8 3.7.9 4.7.9 3.8.0 4.8.0 3.8.1 4.8.1 3.8.2 4.8.10 3.8.3 4.8.11 3.8.4 4.8.2 3.8.5 4.8.3 3.8.6 4.8.4 3.8.7 4.8.5 3.8.8 4.8.6 3.8.9 4.8.7 3.9.0 4.8.8 3.9.1 4.8.9 3.9.2 4.9.0 3.9.3 4.9.0-beta1 3.9.4 4.9.0-beta2 3.9.5 4.9.1 3.9.6 4.9.10 3.9.7 4.9.11 3.9.8 4.9.12 3.9.9 4.9.13 4.0.1 4.9.14 4.0.3 4.9.15 4.0.4 4.9.16 4.0.5 4.9.17 4.0.6 4.9.18 4.0.7 4.9.19 4.0.8 4.9.2 4.0.9 4.9.20 4.1.0 4.9.21 4.1.1 4.9.22 4.1.2 4.9.23 4.1.3 4.9.24 trunk 4.1.4 4.9.25 1.0 4.1.5 4.9.26 1.01 4.1.6 4.9.27 1.02 4.1.7 4.9.28 1.03 4.1.8 4.9.29 1.04 4.1.9 4.9.3 1.05 4.10.0 4.9.30 1.06 4.10.1 4.9.31 1.07 4.10.10 4.9.32 1.08 4.10.11 4.9.33 1.09 4.10.12 4.9.34 2.0 4.10.13 4.9.35 2.0.1 4.10.14 4.9.36 2.0.2 4.10.15 4.9.37 2.0.3 4.10.16 4.9.38 2.0.4 4.10.17 4.9.39 2.0.5 4.10.18 4.9.4 2.0.6 4.10.19 4.9.40 2.0.7 4.10.2 4.9.41 2.0.8 4.10.20 4.9.42 2.0.9 4.10.21 4.9.43 2.1.0 4.10.22 4.9.45 2.1.1 4.10.23 4.9.46 2.1.2 4.10.24 4.9.47 2.1.3 4.10.25 4.9.48 2.1.4 4.10.26 4.9.49 2.1.5 4.10.27 4.9.5 2.1.5-beta1 4.10.28 4.9.50 2.1.6 4.10.29 4.9.51 2.1.7 4.10.3 4.9.52 2.1.8 4.10.30 4.9.53 2.1.9 4.10.31 4.9.54 2.2.0 4.10.32 4.9.55 2.2.1 4.10.33 4.9.56 2.2.2 4.10.34 4.9.57 2.2.3 4.10.35 4.9.6 2.2.4 4.10.36 4.9.7 2.2.5 4.10.37 4.9.8 2.2.6 4.10.38 4.9.9 2.2.7 4.10.39 2.2.8 4.10.4 2.2.9 4.10.40 2.3.0 4.10.41 2.3.1 4.10.42 2.3.2 4.10.43 2.3.3 4.10.44 2.3.4 4.10.45 2.3.5 4.10.46 2.3.6 4.10.47 2.3.7 4.10.48 2.3.8 4.10.49 2.3.9 4.10.5 2.4.0 4.10.50 2.4.1 4.10.51 2.5.0 4.10.52 2.5.1 4.10.53 2.5.2 4.10.54 2.5.3 4.10.55 2.5.4 4.10.56 2.5.5 4.10.57 2.5.6 4.10.58 2.5.7 4.10.59 2.5.8 4.10.6 2.5.9 4.10.60 2.6.0 4.10.61 2.6.1 4.10.62 2.6.2 4.10.63 2.6.3 4.10.64 2.6.4 4.10.65 2.6.5 4.10.66 2.6.6 4.10.67 2.6.7 4.10.68 2.6.8 4.10.69 2.6.9 4.10.7 2.7.0 4.10.70 2.7.1 4.10.71 2.7.2 4.10.72 2.7.3 4.10.73 2.7.4 4.10.74 2.7.5 4.10.75 2.7.6 4.10.76 2.7.7 4.10.77 2.7.8 4.10.78 2.7.9 4.10.79 2.8.0 4.10.8 2.8.1 4.10.80 2.8.2 4.10.81 2.8.3 4.10.82 2.8.4 4.10.83 2.8.5 4.10.84 2.8.6 4.10.85 2.8.7 4.10.86 2.8.8 4.10.87 2.8.9 4.10.88 2.9.0 4.10.89 2.9.1 4.10.9 2.9.2 4.10.90 2.9.3 4.11.0 2.9.4 4.11.1 2.9.5 4.11.10 2.9.6 4.11.11 2.9.7 4.11.12 2.9.8 4.11.13 2.9.9 4.11.14 3.0.0 4.11.15 3.0.1 4.11.16 3.0.2 4.11.17 3.0.3 4.11.18 3.0.4 4.11.19 3.0.5 4.11.2 3.0.6 4.11.20 3.0.7 4.11.21 3.0.8 4.11.22 3.0.9 4.11.23 3.1.0 4.11.24 3.1.1 4.11.25 3.1.2 4.11.26 3.1.3 4.11.27 3.1.4 4.11.28 3.1.5 4.11.29 3.1.6 4.11.3 3.1.7 4.11.30 3.1.8 4.11.31 3.1.9 4.11.32 3.10.0 4.11.33 3.10.1 4.11.34 3.10.2 4.11.35 3.10.3 4.11.36 3.10.4 4.11.37 3.10.5 4.11.38 3.10.6 4.11.39 3.10.7 4.11.4 3.10.8 4.11.40 3.10.9 4.11.41 3.11.0 4.11.42 3.11.1 4.11.43 3.11.2 4.11.44 3.11.3 4.11.45 3.11.4 4.11.46 3.11.5 4.11.47 3.11.6 4.11.48 3.11.7 4.11.49 3.11.8 4.11.5 3.11.9 4.11.50 3.12.0 4.11.51 3.12.1 4.11.52 3.12.2 4.11.53 3.12.3 4.11.54 3.2.0 4.11.55 3.2.1 4.11.56 3.2.2 4.11.57 3.2.3 4.11.58 3.2.4 4.11.59 3.2.5 4.11.6 3.2.6 4.11.60 3.2.7 4.11.61 3.2.8 4.11.62 3.2.9 4.11.63 3.20.0 4.11.64 3.20.1 4.11.65 3.20.2 4.11.66 3.20.3 4.11.67 3.20.4 4.11.68
premium-addons-for-elementor / assets / frontend / js / premium-vscroll.js
premium-addons-for-elementor / assets / frontend / js Last commit date
TweenMax.js 1 year ago anime.js 1 year ago flipster.js 1 year ago headroom.js 1 year ago iscroll.js 1 year ago isotope.js 1 year ago jquery-countdown.js 1 year ago jquery-mousewheel.js 1 year ago jquery-slimscroll.js 1 year ago lottie.js 1 year ago luxon.js 1 year ago markerclusterer.js 1 year ago modal.js 1 year ago motionpath.js 1 year ago pa-gsap.js 1 year ago pa-scrolldir.js 1 year ago premium-addons.js 1 year ago premium-banner.js 1 year ago premium-blog.js 1 year ago premium-button.js 1 year ago premium-carousel-widget.js 1 year ago premium-contact-form.js 1 year ago premium-countdown-timer.js 1 year ago premium-counter.js 1 year ago premium-dis-conditions.js 1 year ago premium-dual-header.js 1 year ago premium-eq-height.js 1 year ago premium-fancy-text.js 1 year ago premium-floating-effects.js 1 year ago premium-global-tooltips.js 1 year ago premium-icon-list.js 1 year ago premium-image-button.js 1 year ago premium-image-scroll.js 1 year ago premium-img-gallery.js 1 year ago premium-maps.js 1 year ago premium-media-wheel.js 1 year ago premium-mini-cart.js 1 year ago premium-mobile-menu.js 1 year ago premium-modal-box.js 1 year ago premium-nav-menu.js 1 year ago premium-notifications.js 1 year ago premium-person.js 1 year ago premium-pinterest-feed.js 1 year ago premium-post-ticker.js 1 year ago premium-progressbar.js 1 year ago premium-search-form.js 1 year ago premium-shape-divider.js 1 year ago premium-svg-drawer.js 1 year ago premium-tcloud.js 1 year ago premium-testimonials.js 1 year ago premium-textual-showcase.js 1 year ago premium-tiktok-feed.js 1 year ago premium-title.js 1 year ago premium-video-box.js 1 year ago premium-vscroll.js 1 year ago premium-weather.js 1 year ago premium-woo-categories.js 1 year ago premium-woo-cta.js 1 year ago premium-woo-products.js 1 year ago premium-world-clock.js 1 year ago premium-wrapper-link.js 1 year ago prettyPhoto.js 1 year ago scrollTrigger.js 1 year ago slick.js 1 year ago tooltipster.js 1 year ago typed.js 1 year ago universal-tilt.js 1 year ago vticker.js 1 year ago
premium-vscroll.js
1130 lines
1 (function ($) {
2 /****** Premium Vertical Scroll Handler ******/
3 var PremiumVerticalScrollHandler = function ($scope, $) {
4
5 var deviceType = elementorFrontend.getCurrentDeviceMode();
6
7 var hiddenClass = "elementor-hidden-" + deviceType;
8
9 // if ("mobile" === deviceType)
10 // hiddenClass = "elementor-hidden-phone";
11
12 if ($scope.closest("section.elementor-element, .e-con").hasClass(hiddenClass)) {
13 return
14 }
15
16 var $vScrollElem = $scope.find(".premium-vscroll-wrap"),
17 $sectionsWrap = $scope.find(".premium-vscroll-sections-wrap"),
18 instance = null,
19 vScrollSettings = $vScrollElem.data("settings");
20
21 //Change back to default animation on touch devices.
22 if (['mobile', 'mobile_extra', 'tablet', 'tablet_extra'].includes(deviceType)) {
23 $sectionsWrap.removeAttr('data-animation data-hijacking');
24 }
25
26 vScrollSettings.deviceType = deviceType;
27
28 instance = new premiumVerticalScroll($vScrollElem, vScrollSettings);
29 instance.init();
30
31 };
32
33 window.premiumVerticalScroll = function ($selector, settings) {
34 var self = this,
35 $window = $(window),
36 currentDevice = elementorFrontend.getCurrentDeviceMode(),
37 isTouch = !['desktop', 'widescreen', 'laptop'].includes(currentDevice),
38 $instance = $selector,
39 checkTemps = $selector.find(".premium-vscroll-sections-wrap").length,
40 $htmlBody = $("html, body"),
41 $itemsList = $(".premium-vscroll-dot-item", $instance),
42 $menuItems = $(".premium-vscroll-nav-item", $instance),
43 defaultSettings = {
44 speed: 700,
45 offset: 0,
46 fullSection: true
47 },
48 settings = $.extend({}, defaultSettings, settings),
49 sections = {},
50 currentSection = null,
51 isScrolling = false,
52 inScope = true,
53 scrollings = [],
54 touchStartY = 0,
55 touchEndY = 0;
56
57 //Extend jQuery default easing.
58 jQuery.extend(jQuery.easing, {
59 easeInOutCirc: function (x, t, b, c, d) {
60 if ((t /= d / 2) < 1)
61 return (-c / 2) * (Math.sqrt(1 - t * t) - 1) + b;
62 return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
63 }
64 });
65
66 self.init = function () {
67
68 if (settings.fullTouch || (!isTouch && settings.fullSection)) {
69
70 if (settings.fullCheckOverflow) {
71
72 self.setSectionsOverflow();
73 }
74 }
75
76 self.setSectionsData();
77
78 self.vscrollEffects();
79
80 $itemsList.on("click.premiumVerticalScroll", self.onNavDotChange);
81 $menuItems.on("click.premiumVerticalScroll", self.onNavDotChange);
82
83 $itemsList.on("mouseenter.premiumVerticalScroll", self.onNavDotEnter);
84
85 $itemsList.on("mouseleave.premiumVerticalScroll", self.onNavDotLeave);
86
87 if ("desktop" === settings.deviceType) {
88 $window.on("scroll.premiumVerticalScroll", self.onWheel);
89 }
90
91 $window.on("resize.premiumVerticalScroll orientationchange.premiumVerticalScroll", self.debounce(50, self.onResize));
92
93 $(document).ready(function () {
94
95 self.setSectionsData();
96
97 //Handle Full Section Scroll.
98 if (settings.fullTouch || (!isTouch && settings.fullSection))
99 self.sectionsOverflowRefresh();
100
101 self.checkCurrentActive();
102
103 });
104
105 self.keyboardHandler();
106
107 self.scrollHandler();
108
109 if (settings.fullSection) {
110
111 self.fullSectionHandler();
112 }
113
114 if (settings.animation) {
115 $instance.find(".premium-vscroll-dots").removeClass("elementor-invisible").addClass("animated " + settings.animation + " animated-" + settings.duration);
116 }
117
118
119 };
120
121 self.checkCurrentActive = function () {
122
123 var firstSection = Object.keys(sections)[0];
124
125 //Get first section offset
126 var firstSectionOffset = sections[firstSection].offset;
127
128 //If page scroll is lower than first section offset, then set current active to 1
129 if (firstSectionOffset >= $window.scrollTop() && firstSectionOffset - $window.scrollTop() < 200) {
130 currentSection = 1;
131 $itemsList.removeClass("active");
132 $($itemsList[0]).addClass("active");
133 }
134
135 //If current active section is defined, then show the dots
136 if (currentSection)
137 $instance.find(".premium-vscroll-dots").removeClass("premium-vscroll-dots-hide");
138
139 };
140
141 /**
142 * Sets the section's overflow scroll.
143 * checks if the section's content height is greater
144 * than the window height and init the section scroller.
145 */
146 self.setSectionsOverflow = function () {
147
148 $itemsList.each(function () {
149
150 var $this = $(this),
151 sectionId = $this.data("menuanchor"),
152 animeType = $instance.find('.premium-vscroll-sections-wrap').data('animation'),
153 $section = $("#" + sectionId),
154 height = animeType ? $section.find('> div').outerHeight() : $section.outerHeight();
155
156 if (height > $window.outerHeight() && height - $window.outerHeight() >= 50) {
157
158 $section.find(checkTemps ? ".elementor" : ".elementor-container").first().wrapInner("<div id='scroller-" + sectionId + "'></div>");
159
160 var isSafari = 'mobile' === elementorFrontend.getCurrentDeviceMode() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
161 slimHeight = isSafari ? $window.outerHeight() + 100 + 'px' : $window.outerHeight();
162
163 $("#scroller-" + sectionId).slimScroll({
164 height: slimHeight,
165 railVisible: false,
166 touchScrollStep: 60
167 });
168
169 var iScrollInstance = new IScroll("#scroller-" + sectionId, {
170 mouseWheel: true,
171 scrollbars: true,
172 hideScrollbars: true,
173 fadeScrollbars: false,
174 disableMouse: true,
175 interactiveScrollbars: false
176 });
177
178 $("#scroller-" + sectionId).data('iscrollInstance', iScrollInstance);
179
180 setTimeout(function () {
181 iScrollInstance.refresh();
182 }, 1500);
183 }
184 });
185 };
186
187 self.sectionsOverflowRefresh = function () {
188
189 $itemsList.each(function () {
190 var $this = $(this),
191 sectionId = $this.data("menuanchor");
192
193 var $section = $("#scroller-" + sectionId);
194
195 var scroller = $section.data('iscrollInstance');
196
197 if (scroller) {
198 scroller.refresh();
199 }
200
201 });
202
203 };
204
205 self.setSectionsData = function () {
206
207 $itemsList.each(function () {
208 var $this = $(this),
209 sectionId = $this.data("menuanchor"),
210 $section = $("#" + sectionId),
211 height = $section.outerHeight();
212
213 //Make sure that section exists in the DOM
214 if ($section[0]) {
215
216 sections[sectionId] = {
217 selector: $section,
218 offset: Math.round($section.offset().top),
219 height: height
220 };
221 }
222 });
223 };
224
225 self.fullSectionHandler = function () {
226
227 var vSection = document.getElementById($instance.attr("id"));
228
229 if (!isTouch || !settings.fullTouch) {
230
231 if (checkTemps) {
232
233 document.addEventListener ?
234 vSection.addEventListener("wheel", self.onWheel, {
235 passive: false
236 }) :
237 vSection.attachEvent("onmousewheel", self.onWheel);
238
239 } else {
240
241 document.addEventListener ?
242 document.addEventListener("wheel", self.onWheel, {
243 passive: false
244 }) :
245 document.attachEvent("onmousewheel", self.onWheel);
246
247 }
248
249 } else {
250 document.addEventListener("touchstart", self.onTouchStart);
251 document.addEventListener("touchmove", self.onTouchMove, {
252 passive: false
253 });
254
255 }
256
257 };
258
259 self.scrollHandler = function () {
260
261 var index = 0;
262
263 for (var section in sections) {
264
265 var $section = sections[section].selector;
266
267 new IntersectionObserver(function (entries, observer) {
268 entries.forEach(function (entry) {
269 if (entry.isIntersecting) {
270
271 var $this = $(entry.target),
272 sectionId = $this.attr("id");
273
274 if (!isScrolling) {
275
276 currentSection = sectionId;
277
278 $itemsList.removeClass("active");
279 $menuItems.removeClass("active");
280
281 $("[data-menuanchor=" + sectionId + "]", $instance).addClass("active");
282 }
283
284 observer.unobserve(entry.target); // to only excecute the callback func once.
285 }
286 });
287 }, {
288 rootMargin: 0 !== index ? "0%" : "-1% 0px 0px 0px"
289 }).observe($section[0]);
290
291 // elementorFrontend.waypoint(
292 // $section,
293 // function () {
294
295 // var $this = $(this),
296 // sectionId = $this.attr("id");
297
298 // if (!isScrolling) {
299
300 // currentSection = sectionId;
301
302 // $itemsList.removeClass("active");
303 // $menuItems.removeClass("active");
304
305 // $("[data-menuanchor=" + sectionId + "]", $instance).addClass("active");
306 // }
307 // }, {
308 // offset: 0 !== index ? "0%" : "-1%",
309 // triggerOnce: false
310 // }
311 // );
312
313 index++;
314 }
315
316 };
317
318 self.keyboardHandler = function () {
319 $(document).keydown(function (event) {
320 if (38 == event.keyCode) {
321 self.onKeyUp(event, "up");
322 }
323
324 if (40 == event.keyCode) {
325 self.onKeyUp(event, "down");
326 }
327 });
328 };
329
330 self.isScrolled = function (sectionID, direction) {
331
332 var $section = $("#scroller-" + sectionID);
333
334 var scroller = $section.data('iscrollInstance');
335
336 if (scroller) {
337 if ('down' === direction) {
338 return (0 - scroller.y) + $section.scrollTop() + 1 + $section.innerHeight() >= $section[0].scrollHeight;
339 } else if ('up' === direction) {
340 return scroller.y >= 0 && !$section.scrollTop();
341 }
342
343 } else {
344 return true;
345 }
346
347 };
348
349 self.getEventsPage = function (e) {
350
351 var events = [];
352
353 events.y = (typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY);
354 events.x = (typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX);
355
356 if (isTouch && typeof e.touches !== 'undefined') {
357 events.y = e.touches[0].pageY;
358 events.x = e.touches[0].pageX;
359 }
360
361 return events;
362
363 };
364
365 self.onTouchStart = function (e) {
366
367 //Prevent page scroll if scrolled down below the last of our sections.
368 inScope = true;
369
370 var touchEvents = self.getEventsPage(e);
371 touchStartY = touchEvents.y;
372
373 };
374
375 self.onTouchMove = function (e) {
376
377 if (inScope) {
378 self.preventDefault(e);
379 }
380
381 if (isScrolling) {
382 self.preventDefault(e);
383 return false;
384 }
385
386 var touchEvents = self.getEventsPage(e);
387
388 touchEndY = touchEvents.y;
389
390 var $target = $(e.target),
391 sectionSelector = checkTemps ? ".premium-vscroll-temp" : ".elementor-top-section, .e-con",
392 $section = $target.parents(sectionSelector).length > 1 ? $target.parents(sectionSelector).last() : $target.closest(sectionSelector),
393 sectionId = $section.attr("id"),
394 newSectionId = false,
395 prevSectionId = false,
396 nextSectionId = false,
397 direction = false,
398 windowScrollTop = $window.scrollTop();
399
400 $(".premium-vscroll-tooltip").hide();
401
402 if (self.beforeCheck()) {
403 sectionId = self.getFirstSection(sections);
404 }
405
406 if (self.afterCheck()) {
407 sectionId = self.getLastSection(sections);
408 }
409
410 if ($target.closest('.premium_maps_map_height').length > 0) {
411
412 var $closestMapSettings = $target.closest('.premium_maps_map_height').data('settings');
413
414 if ($closestMapSettings.scrollwheel)
415 return;
416 }
417
418 //Swiper is added here to prevent scrolling on swipe left/right on touch devices.
419 if ($('.premium-modal-open').length > 0 || $target.closest('.e-widget-swiper').length > 0) {
420 return;
421 }
422
423 var curTime = new Date().getTime();
424
425 if (scrollings.length > 149) {
426 scrollings.shift();
427 }
428
429 //keeping record of the previous scrollings
430 scrollings.push(Math.abs(touchEndY));
431
432 //time difference between the last scroll and the current one
433 var timeDiff = curTime - prevTime;
434 prevTime = curTime;
435
436 //haven't they scrolled in a while?
437 //(enough to be consider a different scrolling action to scroll another section)
438 if (timeDiff > 200) {
439 //emptying the array, we dont care about old scrollings for our averages
440 scrollings = [];
441 }
442
443 if (touchStartY > touchEndY) {
444 direction = 'down';
445 } else if (touchEndY > touchStartY) {
446 direction = 'up';
447 }
448
449 if (sectionId && sections.hasOwnProperty(sectionId)) {
450
451 prevSectionId = self.checkPrevSection(sections, sectionId);
452 nextSectionId = self.checkNextSection(sections, sectionId);
453
454 if ("up" === direction) {
455
456 if (!nextSectionId && sections[sectionId].offset < windowScrollTop) {
457 newSectionId = sectionId;
458 } else {
459 newSectionId = prevSectionId;
460 }
461 }
462
463 if ("down" === direction) {
464
465 if (!prevSectionId && sections[sectionId].offset - settings.offset > windowScrollTop + 5) {
466 newSectionId = sectionId;
467 } else {
468 newSectionId = nextSectionId;
469 }
470 }
471
472 var averageEnd = self.getAverage(scrollings, 10);
473 var averageMiddle = self.getAverage(scrollings, 70);
474 var isAccelerating = averageEnd >= averageMiddle;
475
476 if (newSectionId) {
477 inScope = true;
478 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").removeClass("premium-vscroll-dots-hide");
479
480 if (!self.isScrolled(sectionId, direction)) {
481 return;
482 }
483
484 if (isAccelerating && !isScrolling) {
485 self.onAnchorChange(newSectionId);
486 }
487
488 } else {
489
490 //Make sure the scroll is done.
491 if (averageEnd <= 5) {
492 inScope = false;
493 }
494
495 var $lastselector = checkTemps ? $instance : $("#" + sectionId);
496
497 if ("down" === direction) {
498
499 if ($lastselector.offset().top + $lastselector.innerHeight() - $(document).scrollTop() > 600) {
500
501 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
502
503 }
504
505 } else if ("up" === direction) {
506
507 if ($lastselector.offset().top - $(document).scrollTop() > 200) {
508
509 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
510
511 }
512
513 }
514 }
515
516 } else {
517 inScope = false;
518 }
519
520 };
521
522 self.scrollStop = function () {
523 $htmlBody.stop(true);
524 };
525
526 self.checkNextSection = function (object, key) {
527 var keys = Object.keys(object),
528 idIndex = keys.indexOf(key),
529 nextIndex = (idIndex += 1);
530
531 if (nextIndex >= keys.length) {
532 return false;
533 }
534
535 var nextKey = keys[nextIndex];
536
537 return nextKey;
538 };
539
540 self.checkPrevSection = function (object, key) {
541 var keys = Object.keys(object),
542 idIndex = keys.indexOf(key),
543 prevIndex = (idIndex -= 1);
544
545 if (0 > idIndex) {
546 return false;
547 }
548
549 var prevKey = keys[prevIndex];
550
551 return prevKey;
552 };
553
554 self.debounce = function (threshold, callback) {
555 var timeout;
556
557 return function debounced($event) {
558 function delayed() {
559 callback.call(this, $event);
560 timeout = null;
561 }
562
563 if (timeout) {
564 clearTimeout(timeout);
565 }
566
567 timeout = setTimeout(delayed, threshold);
568 };
569 };
570
571 self.visible = function (selector, partial, hidden) {
572 var s = selector.get(0),
573 vpHeight = $window.outerHeight(),
574 clientSize =
575 hidden === true ? s.offsetWidth * s.offsetHeight : true;
576 if (typeof s.getBoundingClientRect === "function") {
577 var rec = s.getBoundingClientRect();
578 var tViz = rec.top >= 0 && rec.top < vpHeight,
579 bViz = rec.bottom > 0 && rec.bottom <= vpHeight,
580 vVisible = partial ? tViz || bViz : tViz && bViz,
581 vVisible =
582 rec.top < 0 && rec.bottom > vpHeight ? true : vVisible;
583 return clientSize && vVisible;
584 } else {
585 var viewTop = 0,
586 viewBottom = viewTop + vpHeight,
587 position = $window.position(),
588 _top = position.top,
589 _bottom = _top + $window.height(),
590 compareTop = partial === true ? _bottom : _top,
591 compareBottom = partial === true ? _top : _bottom;
592 return (
593 !!clientSize &&
594 (compareBottom <= viewBottom && compareTop >= viewTop)
595 );
596 }
597 };
598
599 self.onNavDotEnter = function () {
600 var $this = $(this),
601 index = $this.data("index");
602
603 if (settings.tooltips) {
604 // make sure only one tool tip is showing.
605 $(".premium-vscroll-tooltip").remove();
606
607 $(
608 '<div class="premium-vscroll-tooltip"><span>' +
609 settings.dotsText[index] +
610 "</span></div>"
611 )
612 .hide()
613 .appendTo($this)
614 .fadeIn(200);
615 }
616 };
617
618 self.onNavDotLeave = function () {
619 $(".premium-vscroll-tooltip").fadeOut(200, function () {
620 $(this).remove();
621 });
622 };
623
624 self.onNavDotChange = function (event) {
625 var $this = $(this),
626 index = $this.index(),
627 sectionId = $this.data("menuanchor"),
628 offset = null;
629
630 if (!sections.hasOwnProperty(sectionId)) {
631 return false;
632 }
633
634 offset = sections[sectionId].offset - settings.offset;
635
636 if (offset < 0)
637 offset = sections[sectionId].offset;
638
639 if (!isScrolling) {
640 isScrolling = true;
641
642 currentSection = sectionId;
643 $menuItems.removeClass("active");
644 $itemsList.removeClass("active");
645
646 if ($this.hasClass("premium-vscroll-nav-item")) {
647 $($itemsList[index]).addClass("active");
648 } else {
649 $($menuItems[index]).addClass("active");
650 }
651
652 $this.addClass("active");
653
654 $htmlBody
655 .stop()
656 .clearQueue()
657 .animate({
658 scrollTop: offset
659 },
660 settings.speed,
661 "easeInOutCirc",
662 function () {
663 isScrolling = false;
664 }
665 );
666 }
667 };
668
669 self.preventDefault = function (event) {
670
671 if (event.preventDefault) {
672
673 event.preventDefault();
674
675 } else {
676
677 event.returnValue = false;
678
679 }
680 };
681
682 self.onAnchorChange = function (sectionId) {
683
684 var $this = $("[data-menuanchor=" + sectionId + "]", $instance),
685 offset = null;
686
687 if (!sections.hasOwnProperty(sectionId)) {
688 return false;
689 }
690
691 offset = sections[sectionId].offset - settings.offset;
692
693 if (offset < 0)
694 offset = sections[sectionId].offset;
695
696 if (!isScrolling) {
697 isScrolling = true;
698
699 if (settings.addToHistory) {
700 window.history.pushState(null, null, "#" + sectionId);
701 }
702
703 currentSection = sectionId;
704
705 $itemsList.removeClass("active");
706 $menuItems.removeClass("active");
707
708 $this.addClass("active");
709
710 $htmlBody.animate({ scrollTop: offset }, settings.speed, "easeInOutCirc");
711
712 setTimeout(function () {
713 isScrolling = false;
714 }, settings.speed < 700 ? 700 : settings.speed);
715 }
716 };
717
718 self.onKeyUp = function (event, direction) {
719
720 //If keyboard is triggered before scroll
721 if (currentSection === 1) {
722 currentSection = $itemsList.eq(0).data("menuanchor");
723 }
724
725 var direction = direction || "up",
726 nextItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance).next(),
727 prevItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance).prev();
728
729 event.preventDefault();
730
731 if (isScrolling) {
732 return false;
733 }
734
735 var $vTarget = self.visible($instance, true, false),
736 dotIndex = $(".premium-vscroll-dot-item.active").index(),
737 animationType = $instance.find('.premium-vscroll-sections-wrap').data('animation');
738
739 if ("up" === direction) {
740 if (prevItem[0]) {
741 prevItem.trigger("click.premiumVerticalScroll");
742 if (dotIndex === $itemsList.length - 1 && !$vTarget) {
743 prevItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance);
744 } else if (dotIndex === $itemsList.length - 1 && ($instance.offset().top + $instance.innerHeight() - $(document).scrollTop() < 600)) {
745 prevItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance);
746 } else {
747 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp:last-of-type>div').removeClass("premium-vscroll-parallax-last");
748 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp>div').removeClass("premium-vscroll-parallax-position");
749 // prevItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance).prev(),
750 }
751
752 }
753 } else {
754 if (nextItem[0]) {
755 nextItem.trigger("click.premiumVerticalScroll");
756 if ($instance.offset().top - $(document).scrollTop() > 200) {
757 nextItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance);
758 }
759 // else {
760 // // nextItem = $(".premium-vscroll-dot-item[data-menuanchor=" + currentSection + "]", $instance).next(),
761 // }
762 }
763 }
764 };
765
766 self.getFirstSection = function (object) {
767 return Object.keys(object)[0];
768 }
769
770 self.getLastSection = function (object) {
771 return Object.keys(object)[Object.keys(object).length - 1];
772 }
773
774 function getScrollData(e) {
775 e = e || window.event;
776
777 var t = e.wheelDelta || -e.deltaY || -e.detail;
778
779 return t;
780 }
781
782 var prevTime = new Date().getTime();
783
784 //Used to unset position CSS property for vertical scroll sections becuase it causes position issue for the content below the widget.
785 function parallaxLastSection() {
786 var $target = $(event.target),
787 sectionSelector = checkTemps ? ".premium-vscroll-temp" : ".elementor-top-section, .e-con",
788 $section = $target.parents(sectionSelector).length > 1 ? $target.parents(sectionSelector).last() : $target.closest(sectionSelector),
789 sectionId = $section.attr("id"),
790 $lastselector = checkTemps ? $instance : $("#" + sectionId),
791 animationType = $instance.find('.premium-vscroll-sections-wrap').data('animation');
792
793 if (animationType) {
794
795 if ($lastselector.offset().top + $lastselector.innerHeight() - $(document).scrollTop() + settings.offset < $window.outerHeight()) {
796 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp:last-of-type > div').addClass("premium-vscroll-parallax-last");
797 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp>div').addClass("premium-vscroll-parallax-position");
798
799 } else {
800 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp:last-of-type > div').removeClass("premium-vscroll-parallax-last");
801 $instance.find('.premium-vscroll-sections-wrap[data-animation=' + animationType + '] .premium-vscroll-temp > div').removeClass("premium-vscroll-parallax-position");
802 }
803 }
804 }
805
806 self.onWheel = function (event) {
807
808 if (inScope && !isTouch) {
809 self.preventDefault(event);
810 }
811
812 var $target = $(event.target),
813 sectionSelector = checkTemps ? ".premium-vscroll-temp" : ".elementor-top-section, .e-con",
814 $section = $target.parents(sectionSelector).length > 1 ? $target.parents(sectionSelector).last() : $target.closest(sectionSelector),
815 sectionId = $section.attr("id"),
816 $vTarget = self.visible($instance, true, false),
817 newSectionId = false,
818 prevSectionId = false,
819 nextSectionId = false,
820 scrollData = getScrollData(event),
821 delta = Math.max(-1, Math.min(1, scrollData)),
822 direction = 0 > delta ? "down" : "up",
823 windowScrollTop = $window.scrollTop(),
824 dotIndex = $(".premium-vscroll-dot-item.active").index();
825
826 if ($target.closest('.premium_maps_map_height').length > 0) {
827
828 var $closestMapSettings = $target.closest('.premium_maps_map_height').data('settings');
829
830 if ($closestMapSettings.scrollwheel)
831 return;
832 }
833
834 //We don't want to return if swiper on desktops.
835 if ($('.premium-modal-open').length > 0) {
836 return;
837 }
838
839 var curTime = new Date().getTime();
840
841 if (scrollings.length > 149) {
842 scrollings.shift();
843 }
844
845 //keeping record of the previous scrollings
846 scrollings.push(Math.abs(scrollData));
847
848 //time difference between the last scroll and the current one
849 var timeDiff = curTime - prevTime;
850 prevTime = curTime;
851
852 //haven't they scrolled in a while?
853 //(enough to be consider a different scrolling action to scroll another section)
854 if (timeDiff > 200) {
855 //emptying the array, we dont care about old scrollings for our averages
856 scrollings = [];
857 }
858
859 parallaxLastSection();
860
861 if (isTouch) {
862
863 $(".premium-vscroll-tooltip").hide();
864
865 if (dotIndex === $itemsList.length - 1 && !$vTarget) {
866 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
867 } else if (dotIndex === 0 && !$vTarget) {
868 if ($instance.offset().top - $(document).scrollTop() > 200) {
869 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
870 }
871 } else {
872 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").removeClass("premium-vscroll-dots-hide");
873 }
874 }
875
876 if (self.beforeCheck()) {
877 sectionId = self.getFirstSection(sections);
878 }
879
880 if (self.afterCheck()) {
881 sectionId = self.getLastSection(sections);
882 }
883
884 if (sectionId && sections.hasOwnProperty(sectionId)) {
885
886 prevSectionId = self.checkPrevSection(sections, sectionId);
887 nextSectionId = self.checkNextSection(sections, sectionId);
888
889 if ("up" === direction) {
890 if (!nextSectionId && sections[sectionId].offset < windowScrollTop) {
891 newSectionId = sectionId;
892 } else {
893 newSectionId = prevSectionId;
894 }
895 } else {
896 if (!prevSectionId && sections[sectionId].offset - settings.offset > windowScrollTop + 5) {
897 newSectionId = sectionId;
898 } else {
899 newSectionId = nextSectionId;
900 }
901 }
902
903 var averageEnd = self.getAverage(scrollings, 10);
904 var averageMiddle = self.getAverage(scrollings, 70);
905 var isAccelerating = averageEnd >= averageMiddle;
906
907 if (newSectionId) {
908 inScope = true;
909 if (!self.isScrolled(sectionId, direction) && !isTouch) {
910 return;
911 }
912
913 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").removeClass("premium-vscroll-dots-hide");
914
915 var iScrollInstance = $("#scroller-" + newSectionId).data('iscrollInstance');
916
917 if (isAccelerating && !isScrolling) {
918 self.onAnchorChange(newSectionId);
919 //Prevent overflow sections from scrolling.
920 // if (iScrollInstance)
921 // iScrollInstance.disable();
922 } else {
923 //Enable overflow sections scroll after 2s.
924 // if (iScrollInstance) {
925 // setTimeout(function () {
926 // iScrollInstance.enable();
927 // }, settings.speed);
928 // }
929 }
930
931 } else {
932 //Make sure the scroll is done.
933 if (averageEnd <= 5) {
934 inScope = false;
935 }
936
937 var $lastselector = checkTemps ? $instance : $("#" + sectionId);
938
939 if ("down" === direction) {
940 if (
941 $lastselector.offset().top +
942 $lastselector.innerHeight() -
943 $(document).scrollTop() >
944 600
945 ) {
946 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
947 }
948 } else if ("up" === direction) {
949 $instance.find(".premium-vscroll-dots, .premium-vscroll-nav-menu").addClass("premium-vscroll-dots-hide");
950 }
951 }
952 }
953 };
954
955 self.beforeCheck = function () {
956 var windowScrollTop = $window.scrollTop(),
957 firstSectionId = self.getFirstSection(sections),
958 offset = sections[firstSectionId].offset,
959 topBorder = windowScrollTop + $window.outerHeight(),
960 visible = self.visible($instance, true, false);
961
962 if (topBorder > offset) {
963 return false;
964 } else if (visible) {
965 return true;
966 }
967 return false;
968 }
969
970 self.afterCheck = function () {
971 var windowScrollTop = $window.scrollTop(),
972 lastSectionId = self.getLastSection(sections),
973 bottomBorder =
974 sections[lastSectionId].offset +
975 sections[lastSectionId].height,
976 visible = self.visible($instance, true, false);
977
978 if (windowScrollTop < bottomBorder) {
979 return false;
980 } else if (visible) {
981 return true;
982 }
983
984 return false;
985 }
986
987 self.onResize = function () {
988 self.setSectionsData();
989 self.sectionsOverflowRefresh();
990 };
991
992 self.getAverage = function (elements, number) {
993 var sum = 0;
994
995 //taking `number` elements from the end to make the average, if there are not enought, 1
996 var lastElements = elements.slice(Math.max(elements.length - number, 1));
997
998 for (var i = 0; i < lastElements.length; i++) {
999 sum = sum + lastElements[i];
1000 }
1001
1002 return Math.ceil(sum / number);
1003 };
1004
1005 self.vscrollEffects = function () {
1006
1007 var animationType = $instance.find('.premium-vscroll-sections-wrap').data('animation');
1008
1009 if (animationType) {
1010
1011 var sectionsAvailable = $instance.find('.premium-vscroll-temp');
1012
1013 //bind the animation to the window scroll event, arrows click and keyboard.
1014 scrollAnimation();
1015
1016 $(window).on('scroll', scrollAnimation);
1017
1018 function scrollAnimation() {
1019
1020 //We don't want scroll functions to be triggered if behance project lightbox is opened.
1021 if ($(".eb-project-overlay").length > 0)
1022 return;
1023
1024 //normal scroll - use requestAnimationFrame (if defined) to optimize performance.
1025 (!window.requestAnimationFrame) ? animateSection() : window.requestAnimationFrame(animateSection);
1026 }
1027
1028 function animateSection() {
1029
1030 var scrollTop = $(window).scrollTop(),
1031 windowHeight = $(window).height();
1032
1033 sectionsAvailable.each(function () {
1034 var actualBlock = $(this),
1035 offset = scrollTop - actualBlock.offset().top;
1036
1037 // according to animation type and window scroll, define animation parameters.
1038 var animationValues = setSectionAnimation(offset, windowHeight, animationType);
1039
1040 transformSection(actualBlock.children('div'), animationValues[0], animationValues[1], animationValues[2], animationValues[3]);
1041
1042 (offset >= 0 && offset < windowHeight) ? actualBlock.addClass('visible') : actualBlock.removeClass('visible');
1043 });
1044 }
1045
1046 function transformSection(element, translateY, rotateXValue, opacityValue, scaleValue) {
1047
1048 element.css({
1049 transform: 'translateY(' + translateY + 'vh) rotateX(' + rotateXValue + ') scale(' + scaleValue + ')',
1050 // rotateX: rotateXValue,
1051 opacity: opacityValue
1052 });
1053 }
1054
1055 function setSectionAnimation(sectionOffset, windowHeight, animationName) {
1056
1057 // select section animation - normal scroll
1058 var translateY = 100,
1059 rotateX = '0deg',
1060 opacity = 1,
1061 scale = 1,
1062 boxShadowBlur = 0;
1063
1064 if (sectionOffset >= -windowHeight && sectionOffset <= 0) {
1065 // section entering the viewport.
1066 translateY = (-sectionOffset) * 100 / windowHeight;
1067
1068 if ('rotate' === animationName) {
1069 translateY = 0;
1070 rotateX = '0deg';
1071 } else if ('scaleDown' === animationName) {
1072 scale = 1;
1073 opacity = 1;
1074 }
1075
1076 } else if (sectionOffset > 0 && sectionOffset <= windowHeight) {
1077 //section leaving the viewport - still has the '.visible' class.
1078 if ('rotate' === animationName) {
1079 opacity = (1 - (sectionOffset / windowHeight)).toFixed(5);
1080 rotateX = sectionOffset * 100 / windowHeight + 'deg';
1081 translateY = 0;
1082 } else if ('scaleDown' === animationName) {
1083 scale = (1 - (sectionOffset * 0.3 / windowHeight)).toFixed(5);
1084 opacity = (1 - (sectionOffset / windowHeight)).toFixed(5);
1085 translateY = 0;
1086 boxShadowBlur = 40 * (sectionOffset / windowHeight);
1087
1088 } else { //parallax
1089 translateY = (-sectionOffset) * 50 / windowHeight;
1090 }
1091
1092 } else if (sectionOffset < -windowHeight) {
1093 //section not yet visible.
1094 translateY = 100;
1095
1096 if ('scaleDown' === animationName) {
1097 scale = 1;
1098 opacity = 1;
1099 }
1100
1101 } else {
1102 //section not visible anymore.
1103 if ('rotate' === animationName) {
1104 translateY = 0;
1105 rotateX = '90deg';
1106
1107 } else if ('scaleDown' === animationName) {
1108 scale = 0;
1109 opacity = 0.7;
1110 translateY = 0;
1111
1112 } else {
1113 translateY = -50;
1114 }
1115 }
1116
1117 return [translateY, rotateX, opacity, scale];
1118 }
1119
1120 }
1121 }
1122 };
1123
1124 $(window).on("elementor/frontend/init", function () {
1125 elementorFrontend.hooks.addAction(
1126 "frontend/element_ready/premium-vscroll.default",
1127 PremiumVerticalScrollHandler
1128 );
1129 });
1130 })(jQuery);