PageSourceSearch

https://munksjo.com/wp-content/themes/uncode/library/js/animations.js?ver=1202972420

js munksjo.com collected 2026-09-24 22:57:51 UTC 14,352 bytes, 401 lines download raw bytes

1(function($) {
2	"use strict";
3
4	UNCODE.animations = function() {
5
6	var runWaypoints_TO,
7		runWaypoints_carousel_TO,
8		runWaypoints_delay = 0,
9	highlightComplexFunc = function($wrap, ev){
10
11		var $lines = $('.heading-line-wrap', $wrap),
12			not_animate = false;
13
14		if ( $wrap.data('animate') === true ) {
15			not_animate = true;
16		}
17
18		var $rotatingTxt = $('.uncode-rotating-text-start', $wrap);
19		if ( $rotatingTxt.length && $rotatingTxt.attr('data-animated') !== 'true' ) {
20			return;
21		}
22
23		$lines.each(function(_key, _value){
24			var $line = $(_value),
25				$inners = $('.split-word-inner', $line),
26				$highlights = $('.heading-text-highlight-inner', $line);
27
28			var highlitInnerFunc = function(ev){
29				var delay = 0;
30				$highlights.each(function(h_key, high){
31					var $highlight = $(high),
32						$split = $highlight.closest('.split-word:not(.uncode-rotating-span)'),
33						$nextSplit = $split.nextUntil(),
34						$next = $('.heading-text-highlight-inner', $nextSplit),
35						countCh = $split.text().length;
36
37					$highlight.css({
38						'-webkit-transition-duration': (30 * countCh) + 'ms',
39						'-moz-transition-duration': (30 * countCh) + 'ms',
40						'-o-transition-duration': (30 * countCh) + 'ms',
41						'transition-duration': (30 * countCh) + 'ms',
42					});
43
44					delay += (30 * countCh);
45
46					$next.css({
47						'-webkit-transition-delay': delay + 'ms',
48						'-moz-transition-delay': delay + 'ms',
49						'-o-transition-delay': delay + 'ms',
50						'transition-delay': delay + 'ms',
51					});
52				});
53				$highlights.removeAttr('data-animated');
54				if ( _key+1 === $lines.length ) {
55					$wrap.data('animate', true);
56				}
57			};
58
59			if ( $('.heading-text-highlight-inner[data-animated="yes"]', $line).length ) {
60				if ( not_animate ) {
61					$highlights.each(function(h_key, high){
62						var $highlight = $(high);
63						$highlight.css({
64							'-webkit-transition-duration': '0ms',
65							'-moz-transition-duration': '0ms',
66							'-o-transition-duration': '0ms',
67							'transition-duration': '0ms',
68						});
69					});
70					$highlights.removeAttr('data-animated');
71				} else {
72					if ( typeof ev !== 'undefined' && ev.type === 'defer-highlights' ) {
73						highlitInnerFunc();
74					} else {
75						$inners.last().one('webkitAnimationEnd oanimationend mozAnimationEnd msAnimationEnd animationEnd', highlitInnerFunc);
76					}
77				}
78			}
79		});
80	};
81
82	$.each($('.header-content-inner'), function(index, val) {
83		var element = $(val),
84			transition = '';
85		if (element.hasClass('top-t-bottom')) transition = 'top-t-bottom';
86		if (element.hasClass('bottom-t-top')) transition = 'bottom-t-top';
87		if (element.hasClass('left-t-right')) transition = 'left-t-right';
88		if (element.hasClass('right-t-left')) transition = 'right-t-left';
89		if (element.hasClass('zoom-in')) transition = 'zoom-in';
90		if (element.hasClass('zoom-out')) transition = 'zoom-out';
91		if (element.hasClass('alpha-anim')) transition = 'alpha-anim';
92		if (element.hasClass('slight-anim')) transition = 'slight-anim';
93		if (transition != '') {
94			$(val).removeClass(transition);
95			var container = element,
96				containerDelay = container.attr('data-delay'),
97				containerSpeed = container.attr('data-speed'),
98				items = $('.header-title > *, .post-info', container);
99			$.each(items, function(index, val) {
100				var element = $(val),
101					//speedAttr = (containerSpeed == undefined) ? containerSpeed : '',
102					delayAttr = (containerDelay != undefined) ? containerDelay : 400;
103				if (!element.hasClass('animate_when_almost_visible') && !element.hasClass('translate_when_almost_visible')) {
104					delayAttr = Number(delayAttr) + (400 * index);
105					if (containerSpeed != undefined) element.attr('data-speed', containerSpeed);
106					element.addClass(transition + ' animate_when_almost_visible').attr('data-delay', delayAttr);
107				}
108			});
109			container.css('opacity', 1);
110		}
111	});
112
113	function animate_css_grids_on_load() {
114		$('.cssgrid-system').each(function() {
115			var grid = $(this);
116			var sequential = grid.hasClass('cssgrid-animate-sequential') ? true : false;
117			UNCODE.animate_css_grids(grid, grid.find('.tmb-grid'), 0, sequential, false);
118		});
119	}
120
121	var delayAdd = 0;
122
123	window.waypoint_animation = function(ev) {
124		$.each($('.translate_when_almost_visible:not(.start_animation), .animate_when_almost_visible:not(.start_animation):not(.t-inside):not(.drop-image-separator), .tmb-linear .animate_when_almost_visible:not(.start_animation), .index-scroll .animate_when_almost_visible, .tmb-media .animate_when_almost_visible:not(.start_animation), .animate_when_almost_visible.has-rotating-text, .custom-grid-container .animate_when_almost_visible:not(.start_animation)').filter(function(){
125				var $el = $(this);
126				if (!$el.is('[data-delay-seq]')) return true;
127				return $el.is('[data-delay]');
128			}), function(index, val) {
129			if ( $(val).hasClass('el-text-split') || ( ( $(val).closest('.unscroll-horizontal').length || $(val).closest('.index-scroll').length || $(val).closest('.tab-pane:not(.active)').length || $(val).closest('.panel:not(.active-group)').length || $(val).closest('.un-submenu').length || $(val).closest('#uncode-mobile-menu-block').length || $(val).closest('.has-unblock').length ) && !SiteParameters.is_frontend_editor ) ) {
130				return true;
131			}
132			if (UNCODE.isUnmodalOpen && !val.closest('#unmodal-content')) {
133				return;
134			}
135			var run = true,
136				$carousel = $(val).closest('.owl-carousel'),
137				marquee = $(val).closest('.tmb-linear').length;
138			if ( $carousel.length ) {
139				run = false;
140			}
141			if ( $(val).closest('.megamenu-block-wrapper').length ) {
142				run = false;
143			}
144			if (run) {
145				new Waypoint({
146					context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
147					element: val,
148					handler: function() {
149						var element = $(this.element),
150							index = element.index(),
151							delayAttr = element.attr('data-delay');
152						if (delayAttr == undefined) delayAttr = 0;
153						// delayAttr = parseFloat(delayAttr) + delayAdd;
154						// if ( marquee ) {
155						// 	delayAdd += 50;
156						// } else {
157						// 	delayAdd = 0;
158						// }
159						requestTimeout(function() {
160							element.addClass('start_animation');
161						}, delayAttr);
162						if (!UNCODE.isUnmodalOpen) {
163							this.destroy();
164						}
165					},
166					offset: UNCODE.isFullPage ? '100%' : '90%'
167				});
168			}
169		});
170		$.each($('.animate_inner_when_almost_visible'), function(index, val) {
171			if (UNCODE.isUnmodalOpen && !val.closest('#unmodal-content')) {
172				return;
173			}
174			var run = true,
175				$carousel = $(val).closest('.owl-carousel');
176			if ( $carousel.length ) {
177				run = false;
178			}
179			if (run) {
180				new Waypoint({
181					context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
182					element: val,
183					handler: function() {
184						var $element = $(this.element),
185							$childs = $('.animate_when_parent_almost_visible', $element);
186						$childs.each(function(key,el){
187							var $child = $(el),
188								delaySpeed = $child.attr('data-speed'),
189								delayAttr = $child.attr('data-delay'),
190								intervalAttr = $child.attr('data-interval');
191							if (delayAttr == undefined) {
192								delayAttr = 50*key;
193							}
194							requestTimeout(function() {
195								$child.addClass('start_animation');
196								if ( $child.hasClass('anim-line-checker') ) {
197									$child.on('webkitAnimationEnd oanimationend mozAnimationEnd msAnimationEnd animationEnd', function(e) {
198										var $line = $child.closest('.heading-line-wrap');
199									});
200								}
201								var $wrapText = $child.closest('.animate_inner_when_almost_visible');
202								highlightComplexFunc($wrapText, ev);
203								if ( $child.hasClass('anim-tot-checker') ) {
204									$child.on('webkitAnimationEnd oanimationend mozAnimationEnd msAnimationEnd animationEnd', function(e) {
205										if ( $child.hasClass('anim-tot-checker') ) {
206											$wrapText.addClass('already-animated');
207											$element.trigger('already-animated');
208										}
209									});
210								}
211							}, delayAttr );
212						});
213						$element.addClass('start_animation');
214						if (!UNCODE.isUnmodalOpen) {
215							this.destroy();
216						}
217					},
218					offset: UNCODE.isFullPage ? '100%' : '90%'
219				});
220			}
221		});
222	}
223	window.waypoint_carousel_animation = function(ev) {
224		$.each($('.owl-carousel').find('.animate_when_almost_visible:not(.start_animation):not(.t-inside):not(.drop-image-separator), .tmb-media .animate_when_almost_visible:not(.start_animation)'), function(index, val) {
225			if ( $(val).hasClass('el-text-split') ) {
226				return true;
227			}
228			if (UNCODE.isUnmodalOpen && !val.closest('#unmodal-content')) {
229				return;
230			}
231			var run = true,
232				$carousel = $(val).closest('.owl-carousel'),
233				$first_item = $(val).closest('.owl-item[data-index="1"]'),
234				$all_first = $('.owl-item[data-index="1"]', $carousel);
235			if ( ! ( $first_item.length && $first_item.attr('data-already-reached') !== 'true' ) && $carousel.attr('data-front-edited') !== 'true' ) {
236				run = false;
237			}
238			if (run) {
239				new Waypoint({
240					context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
241					element: val,
242					handler: function() {
243						var element = $(this.element),
244							index = element.index(),
245							delayAttr = element.attr('data-delay');
246						if (delayAttr == undefined) delayAttr = 0;
247						requestTimeout(function() {
248							if ( $first_item.length && $first_item.attr('data-already-reached') !== 'true' ) {
249								$all_first.attr('data-already-reached', 'true');
250							}
251							element.addClass('start_animation');
252						}, delayAttr);
253						if (!UNCODE.isUnmodalOpen) {
254							this.destroy();
255						}
256					},
257					offset: UNCODE.isFullPage ? '100%' : '90%'
258				});
259			}
260		});
261		$.each($('.owl-carousel').find('.animate_inner_when_almost_visible'), function(index, val) {
262			if (UNCODE.isUnmodalOpen && !val.closest('#unmodal-content')) {
263				return;
264			}
265			var run = true,
266				$carousel = $(val).closest('.owl-carousel'),
267				$first_item = $(val).closest('.owl-item[data-index="1"]'),
268				$all_first = $('.owl-item[data-index="1"]', $carousel);
269			if ( ! ( $first_item.length && $first_item.attr('data-already-reached') !== 'true' ) && $carousel.attr('data-front-edited') !== 'true' ) {
270				run = false;
271			}
272			if (run) {
273				new Waypoint({
274					context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
275					element: val,
276					handler: function() {
277						var $element = $(this.element),
278							$childs = $('.animate_when_parent_almost_visible', $element);
279						$childs.each(function(key,el){
280							var $child = $(el),
281								delaySpeed = $child.attr('data-speed'),
282								delayAttr = $child.attr('data-delay'),
283								intervalAttr = $child.attr('data-interval');
284							if (delayAttr == undefined) {
285								delayAttr = 50*key;
286							}
287							requestTimeout(function() {
288								if ( $first_item.length && $first_item.attr('data-already-reached') !== 'true' ) {
289									$all_first.attr('data-already-reached', 'true');
290								}
291								$child.addClass('start_animation');
292								if ( $child.hasClass('anim-line-checker') ) {
293									$child.on('webkitAnimationEnd oanimationend mozAnimationEnd msAnimationEnd animationEnd', function(e) {
294										var $line = $child.closest('.heading-line-wrap');
295									});
296								}
297								var $wrapText = $child.closest('.animate_inner_when_almost_visible');
298								highlightComplexFunc($wrapText, ev);
299								if ( $child.hasClass('anim-tot-checker') ) {
300									$child.on('webkitAnimationEnd oanimationend mozAnimationEnd msAnimationEnd animationEnd', function(e) {
301										if ( $child.hasClass('anim-tot-checker') ) {
302											$wrapText.addClass('already-animated');
303										}
304									});
305								}
306							}, delayAttr );
307						});
308						$element.addClass('start_animation');
309						if (!UNCODE.isUnmodalOpen) {
310							this.destroy();
311						}
312					},
313					offset: UNCODE.isFullPage ? '100%' : '90%'
314				});
315			}
316		});
317	}
318
319	var runWaypoints = function(ev){
320		if ( typeof runWaypoints_TO !== 'undefined' && runWaypoints_TO !== '' ) {
321			runWaypoints_delay = 400;
322		}
323		clearRequestTimeout(runWaypoints_TO);
324		runWaypoints_TO = requestTimeout(function() {
325			window.waypoint_animation(ev);
326		}, runWaypoints_delay);
327
328		clearRequestTimeout(runWaypoints_carousel_TO);
329		runWaypoints_carousel_TO = requestTimeout(function() {
330			window.waypoint_carousel_animation(ev);
331		}, 400);
332	};
333	runWaypoints();
334	animate_css_grids_on_load();
335
336	$( document.body ).on( 'uncode_waypoints defer-highlights', function(ev) {
337		runWaypoints(ev);
338	});
339	if ( $('body').hasClass('compose-mode') && typeof window.parent.vc !== 'undefined' ) {
340		window.parent.vc.events.on( 'shortcodeView:updated', runWaypoints );
341		window.parent.vc.events.on( 'shortcodeView:ready', runWaypoints );
342	}
343};
344
345UNCODE.animate_css_grids = function(container, elements, startIndex, sequential, filtering) {
346	var $allItems = elements.length - startIndex,
347		showed = 0,
348		index = 0,
349		use_index = false
350		;
351
352	if (filtering) {
353		if (sequential) {
354			use_index = true;
355		}
356		sequential = false;
357	}
358
359	$.each(elements, function(index, val) {
360		var $this = $(val),
361			elInner = $('> .t-inside', val);
362
363		if ( ( UNCODE.isUnmodalOpen && !val.closest('#unmodal-content') ) || $(val).closest('.un-submenu').length || $(val).closest('uncode-mobile-menu-block').length ) {
364			return;
365		}
366		if (val[0]) val = val[0];
367
368		if (elInner.hasClass('animate_when_almost_visible') && !elInner.hasClass('force-anim')) {
369			new Waypoint({
370				context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
371				element: val,
372				handler: function() {
373					var element = $('> .t-inside', this.element),
374						parent = $(this.element);
375					var _index = use_index? index : 0;
376
377					var delay = (!sequential) ? _index : ((startIndex !== 0) ? index - $allItems : index),
378						delayAttr = parseInt(element.attr('data-delay'));
379					if (isNaN(delayAttr)) delayAttr = 100;
380					if (sequential || use_index) {
381						delay -= showed;
382					}
383					var objTimeout = requestTimeout(function() {
384						element.removeClass('zoom-reverse').addClass('start_animation');
385						showed = index;
386					}, delay * delayAttr);
387					parent.data('objTimeout', objTimeout);
388					if (!UNCODE.isUnmodalOpen) {
389						this.destroy();
390					}
391				},
392				offset: UNCODE.isFullPage ? '100%' : '90%'
393			});
394		}
395
396		index++;
397	});
398};
399
400
401})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.