PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / assets / js / addons / ma-timeline.js

ma-timeline.js in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at assets/js/addons/ma-timeline.js

169 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){
2 //#region dev/js/addons/free/ma-timeline.js
3 /**
4 * Inlined from common/utils.js so this widget builds as a self-contained
5 * script. The premium build re-imports this file and cannot resolve nested
6 * imports, which would leave a dangling import in the minified output.
7 */
8 function getItems(items, itemKey) {
9 if (itemKey) {
10 var keyStack = itemKey.split("."), currentKey = keyStack.splice(0, 1);
11 if (!keyStack.length) return items[currentKey];
12 if (!items[currentKey]) return;
13 return getItems(items[currentKey], keyStack.join("."));
14 }
15 return items;
16 }
17 function getElementSettings($element, setting) {
18 var elementSettings = {}, modelCID = $element.data("model-cid");
19 if (typeof elementorFrontend !== "undefined" && elementorFrontend.isEditMode() && modelCID) {
20 var settings = elementorFrontend.config.elements.data[modelCID], type = settings.attributes.widgetType || settings.attributes.elType, settingsKeys = elementorFrontend.config.elements.keys[type];
21 if (!settingsKeys) {
22 settingsKeys = elementorFrontend.config.elements.keys[type] = [];
23 jQuery.each(settings.controls, function(name, control) {
24 if (control.frontend_available) settingsKeys.push(name);
25 });
26 }
27 jQuery.each(settings.getActiveControls(), function(controlKey) {
28 if (-1 !== settingsKeys.indexOf(controlKey)) elementSettings[controlKey] = settings.attributes[controlKey];
29 });
30 } else elementSettings = $element.data("settings") || {};
31 return getItems(elementSettings, setting);
32 }
33 function getUniqueLoopScopeId($scope) {
34 if ($scope.data("jltma-template-widget-id")) return $scope.data("jltma-template-widget-id");
35 return $scope.data("id");
36 }
37 (function($, window, document, undefined) {
38 $.maTimeline = function(element, options) {
39 var defaults = {
40 scope: $(window),
41 points: ".timeline-item__point",
42 lineLocation: 50
43 };
44 var plugin = this;
45 plugin.opts = {};
46 var $window = null, $viewport = $(window), $element = $(element), latestKnownScrollY = -1, latestKnownWindowHeight = -1, currentScrollY = 0, currentWindowHeight = 0, ticking = false, $line = $element.find(".jltma-timeline__line"), $progress = $line.find(".jltma-timeline__line__inner"), $cards = $element.find(".jltma-timeline__item");
47 plugin.init = function() {
48 plugin.opts = $.extend({}, defaults, options);
49 plugin._construct();
50 };
51 plugin._construct = function() {
52 $window = plugin.opts.scope;
53 currentScrollY = $window.scrollTop();
54 currentWindowHeight = $(window).height();
55 plugin.events();
56 plugin.requestTick();
57 plugin.animateCards();
58 };
59 plugin.requestTick = function() {
60 if (!ticking) requestAnimationFrame(plugin.refresh);
61 ticking = true;
62 };
63 plugin.animateCards = function() {
64 $cards.each(function() {
65 if ($(this).offset().top <= $window.scrollTop() + $viewport.outerHeight() * .95) $(this).addClass("bounce-in");
66 });
67 };
68 plugin.events = function() {
69 $window.on("scroll", plugin.onScroll);
70 $(window).on("resize", plugin.onResize);
71 };
72 plugin.onScroll = function() {
73 currentScrollY = $window.scrollTop();
74 plugin.requestTick();
75 plugin.animateCards();
76 };
77 plugin.onResize = function() {
78 currentScrollY = $window.scrollTop();
79 currentWindowHeight = $window.height();
80 plugin.requestTick();
81 };
82 plugin.setup = function() {
83 $line.css({
84 "top": $cards.first().find(plugin.opts.points).offset().top - $cards.first().offset().top,
85 "bottom": $element.offset().top + $element.outerHeight() - $cards.last().find(plugin.opts.points).offset().top
86 });
87 };
88 plugin.refresh = function() {
89 ticking = false;
90 if (latestKnownWindowHeight !== currentWindowHeight) plugin.setup();
91 if (latestKnownScrollY !== currentScrollY || latestKnownWindowHeight !== currentWindowHeight) {
92 latestKnownScrollY = currentScrollY;
93 latestKnownWindowHeight = currentWindowHeight;
94 plugin.progress();
95 }
96 };
97 plugin.progress = function() {
98 var _coeff = 100 / plugin.opts.lineLocation, _last_pos = $cards.last().find(plugin.opts.points).offset().top, _pos = $window.scrollTop() - $progress.offset().top + $viewport.outerHeight() / _coeff;
99 if (_last_pos <= $window.scrollTop() + $viewport.outerHeight() / _coeff) _pos = _last_pos - $progress.offset().top;
100 $progress.css({ "height": _pos + "px" });
101 $cards.each(function() {
102 if ($(this).find(plugin.opts.points).offset().top < $window.scrollTop() + $viewport.outerHeight() / _coeff) $(this).addClass("is--focused");
103 else $(this).removeClass("is--focused");
104 });
105 };
106 plugin.destroy = function() {
107 $element.removeData("maTimeline");
108 };
109 plugin.init();
110 };
111 $.fn.maTimeline = function(options) {
112 return this.each(function() {
113 $.fn.maTimeline.destroy = function() {
114 if ("undefined" !== typeof plugin) {
115 $(this).data("maTimeline").destroy();
116 $(this).removeData("maTimeline");
117 }
118 };
119 if (undefined === $(this).data("maTimeline")) {
120 var plugin = new $.maTimeline(this, options);
121 $(this).data("maTimeline", plugin);
122 }
123 });
124 };
125 })(jQuery, window, document);
126 /**
127 * Start timeline widget script
128 */
129 (function($, elementor) {
130 "use strict";
131 var JLTMA_Timeline = function($scope, $) {
132 var elementSettings = getElementSettings($scope), $timeline = $scope.find(".jltma-timeline");
133 $scope.find(".jltma-timeline-slider");
134 var $timeline_type = elementSettings.ma_el_timeline_type || "custom", $timeline_layout = elementSettings.ma_el_timeline_design_type || "vertical", timelineArgs = {};
135 getUniqueLoopScopeId($scope);
136 if ($timeline_layout === "horizontal") {
137 var $carousel = $scope.find(".jltma-timeline-carousel-slider");
138 if (!$carousel.length) return;
139 var $carouselContainer = $scope.find(".swiper"), $settings = $carousel.data("settings"), Swiper = elementorFrontend.utils.swiper;
140 async function initSwiper() {
141 await new Swiper($carouselContainer[0], $settings);
142 if ($settings.pauseOnHover) $($carouselContainer).hover(function() {
143 this.swiper.autoplay.stop();
144 }, function() {
145 this.swiper.autoplay.start();
146 });
147 }
148 initSwiper();
149 }
150 if ($timeline_layout === "vertical" || $timeline_type === "post") {
151 var timelineArgs = {};
152 function init() {
153 if (typeof elementorFrontend !== "undefined" && elementorFrontend.isEditMode()) timelineArgs.scope = window.elementor.$previewContents;
154 if ("undefined" !== typeof elementSettings.line_location && elementSettings.line_location.size) timelineArgs.lineLocation = elementSettings.line_location.size;
155 $timeline.maTimeline(timelineArgs);
156 }
157 init();
158 }
159 };
160 $(window).on("elementor/frontend/init", function() {
161 elementorFrontend.hooks.addAction("frontend/element_ready/ma-timeline.default", JLTMA_Timeline);
162 });
163 })(jQuery, window.elementorFrontend);
164 /**
165 * End timeline widget script
166 */
167 //#endregion
168 })();
169