PageSourceSearch

https://visapourlimage.com/wp-content/themes/uncode/library/js/textMarquee.js?ver=14690446

js visapourlimage.com collected 2026-09-24 20:05:55 UTC 10,838 bytes, 413 lines download raw bytes

1(function($) {
2	"use strict";
3
4	var marqueeCheckResize,
5	initMarquee;
6
7UNCODE.textMarquee = function( $titles ) {
8
9	var isInitMarque = false;
10	var lastMarqueeDocH = Math.round($(document).height());
11
12	var initTextMarquee = function( $titles ){
13
14		if ( typeof $titles == 'undefined' ) {
15			$titles = $('.un-text-marquee');
16		}
17
18		if ( ! $titles.length ) {
19			return;
20		}
21
22		isInitMarque = true;
23
24		var stableHeight = UNCODE.wheight;
25
26		$titles.each(function(){
27			var $title = $(this),
28				marqueeNS = '.textMarquee-' + Math.random().toString(36).slice(2),
29				$span = $('> span, > i > span', $title),
30				txt,
31				first = true,
32				dataSpeed = parseFloat( $title.closest('.heading-text').attr('data-marquee-speed') ),
33				dataSpace = parseFloat( $title.closest('.heading-text').attr('data-marquee-space') ),
34				dataTrigger = $title.closest('.heading-text').attr('data-marquee-trigger'),
35				hasSticky = false,
36				dataNavBar = $title.closest('.heading-text').attr('data-marquee-navbar'),
37				dataNavBarMobile = $title.closest('.heading-text').attr('data-marquee-navbar-mobile'),
38				newW = UNCODE.wwidth,
39				marqueeTL, inview,
40				isInMenu = $title.closest('.megamenu-block-wrapper').length;
41
42
43			var getStickyBound = function() {
44				var $sticky = $title.closest('.sticky-trigger, .sticky-element');
45
46				if ( $sticky.length ) {
47					var $pinSpacer = $sticky.closest('.pin-spacer');
48					return $pinSpacer.length ? $pinSpacer : $sticky;
49				}
50
51				var $pinSpacerOnly = $title.closest('.pin-spacer');
52
53				if ( $pinSpacerOnly.length ) {
54					return $pinSpacerOnly;
55				}
56
57				return $title.closest('.vc_row');
58			};
59
60			if ( $title.closest('.sticky-trigger').length || $title.closest('.sticky-element').length || $title.closest('.pin-spacer').length ) {
61				hasSticky = true;
62				dataTrigger = 'row';
63			}
64
65			if ( UNCODE.wwidth <= UNCODE.mediaQuery ) {
66				dataNavBar = dataNavBarMobile;
67			}
68
69			dataSpeed = isNaN(dataSpeed) ? 0 : dataSpeed;
70			dataSpace = isNaN(dataSpace) ? 'default' : dataSpace;
71			var dataX = dataSpeed;
72
73			dataSpeed += 5;
74
75			$('.marquee-clone-wrap', $title).remove();
76
77			txt = $span.html();
78
79			if ( ! $('.marquee-original-core', $span).length ) {
80				txt = $span.html();
81				$span = $('> span, > i > span', $title).wrapInner('<span class="marquee-original-core" />').addClass('marquee-original');
82			} else {
83				txt = $('.marquee-original-core', $span).html();
84			}
85
86			var spanW,
87				$prepended = $('<span class="marquee-clone-wrap wrap-prepended" />'),
88				$appended = $('<span class="marquee-clone-wrap wrap-appended" />'),
89				speed = 10 - dataSpeed;
90
91			$span.prepend($prepended);
92			$span.append($appended);
93
94			var continuousTextMarquee = function () {
95				var bound = $title
96						.css({
97							transform: "none",
98							opacity: 0,
99						})
100						.offset(),
101					ease = "none";
102
103				var xStrt =
104						first || $title.hasClass("un-marquee-infinite")
105							? 0
106							: UNCODE.wwidth - bound.left,
107					xEnd = $title.hasClass("un-marquee-infinite")
108						? spanW
109						: spanW + bound.left,
110					xSpeed =
111						((xEnd + xStrt) / (dataSpeed * dataSpeed * dataSpeed) / 5) *
112						dataSpeed,
113					direction = $title.hasClass("un-marquee-opposite") ? 1 : -1,
114					speedSlow = (xEnd + xStrt) / 45,
115					transFormVal,
116					translX;
117
118				if ( typeof marqueeTL !== 'undefined' && marqueeTL !== null ) {
119					marqueeTL.kill();
120				}
121
122				marqueeTL = new TimelineMax({ paused: true, reversed: true });
123				marqueeTL.play();
124
125				var inViewElement =
126						dataTrigger === "row" ? ( hasSticky ? getStickyBound()[0] : $title.closest(".vc_row")[0] ) : $title[0],
127					wayOff =
128						dataTrigger === "row" && dataNavBar === "yes"
129							? UNCODE.menuHeight
130							: 0;
131
132				if ( isInMenu ) {
133					$(document).on('un-menu-show.marquee', function(e, $ul){
134						marqueeTL.restart();
135					});
136					$(document).on('un-menu-hide.marquee', function(e, $ul){
137						marqueeTL.pause();
138					});
139				} else {
140					inview = new Waypoint.Inview({
141						element: inViewElement,
142						offset: wayOff,
143						enter: function (direction) {
144							marqueeTL.play();
145						},
146						exited: function (direction) {
147							if (!$title.closest(".pin-spacer").length) {
148								marqueeTL.pause();
149							}
150						},
151					});
152				}
153
154				if ($title.hasClass("un-marquee-hover")) {
155					var $column = $title.closest(".wpb_column"),
156						$col_link = $(".col-link", $column),
157						$hover_sel = $title;
158
159					if ($col_link.length) {
160						$hover_sel = $title.add($column);
161					}
162					$hover_sel
163						.on("mouseover", function () {
164							ease = "power2.out";
165							transFormVal = $title.css("transform").split(/[()]/)[1];
166							translX = transFormVal.split(",")[4];
167							speedSlow = (xEnd + (xStrt - translX)) / 45;
168							marqueeTL.duration(speedSlow);
169						})
170						.on("mouseout", function () {
171							ease = "power2.in";
172							transFormVal = $title.css("transform").split(/[()]/)[1];
173							translX = transFormVal.split(",")[4];
174							speedSlow =
175								((xEnd + (xStrt - translX)) /
176									(dataSpeed * dataSpeed * dataSpeed) /
177									5) *
178								dataSpeed;
179							marqueeTL.duration(speedSlow);
180						});
181				}
182		
183				gsap.killTweensOf($title);
184				marqueeTL.fromTo( $title, {
185					opacity: 1,
186					x: xStrt * direction * -1
187				},
188				{
189					duration: xSpeed,
190					x: xEnd * direction,
191					onComplete: function(){
192						first = false;
193						if ( isInMenu ) {
194							marqueeTL.restart();
195						} else {
196							continuousTextMarquee();
197						}
198					},
199					onUpdate: function(){
200						if ( ! $title[0].isConnected ) {
201							marqueeTL.kill();
202							initTextMarquee();
203						}
204					},
205					ease: ease
206				});
207		
208			};
209			
210			var runTextMarquee = function(){
211				var $row = $title.closest('.vc_row');
212				if ( hasSticky ) {
213					$row = getStickyBound();
214				}
215				var $bound = (dataTrigger === 'row' || dataTrigger === 'row-middle') ? $row : $title;
216
217				if ( !$bound.length ) {
218					return;
219				}
220
221				if ( $title.data('marqueeScrollActive') ) {
222					return;
223				}
224
225				var boundEl = $bound[0],
226					titleEl = $title[0],
227					direction = $title.hasClass('un-marquee-scroll-opposite') ? -1 : 1,
228					dataMove = dataX >= 0 ? 1 + dataX : -1 * ( 5 / (dataX - 0.5) * 0.25);
229
230				$title.data('marqueeScrollActive', true);
231
232				var loop = function(){
233					if ( ! titleEl.isConnected ) {
234						$title.data('marqueeScrollActive', false);
235						initTextMarquee();
236						return;
237					}
238
239					var bound = boundEl.getBoundingClientRect(),
240						bound_top = bound.top,
241						gsap_calc = ( ( stableHeight * 0.35 - bound_top ) * dataMove ) * 0.5 * direction;
242
243					if ( dataTrigger === 'row' || dataTrigger === 'row-middle' ) {
244						if ( dataTrigger === 'row-middle' ) {
245							bound_top = (bound.top + bound.height*0.5) - (stableHeight * 0.5);
246						}
247						if ( dataNavBar === 'yes' ) {
248							bound_top = bound_top - UNCODE.menuHeight;
249						}
250						gsap_calc = ( bound_top * dataMove ) * 0.5 * direction;
251					}
252
253					titleEl.style.transform = 'translate3d(' + gsap_calc + 'px, 0, 0)';
254
255					requestAnimationFrame( loop );
256				};
257
258				requestAnimationFrame( loop );
259			};
260
261			var cloneSpan = function($_title, cntnt){
262
263				if ( $_title.hasClass('un-marquee-infinite') ) {
264					$('> span.marquee-clone-wrap', $_title).text('');
265				}
266
267				gsap.to( $_title, {
268					duration: 0,
269					x: 0
270				});
271
272				spanW = $span.outerWidth();
273
274
275				if ( !spanW ) {
276					return;
277				}
278
279				var part = Math.ceil( UNCODE.wwidth / spanW ) * 2,
280					spaceSpan = dataSpace !== 'default' ? '<span class="marquee-space-' + dataSpace + '">\u00A0</span>' : "\u00A0";
281
282				if ( $_title.hasClass('un-marquee-infinite') ) {
283
284					for ( var i = 0; i < part; i++ ) {
285						$prepended.append(cntnt + spaceSpan);
286						$appended.append(cntnt + spaceSpan);
287					}
288				}
289
290				if ( $('body').hasClass('compose-mode') ) {
291					$('.uncode_fe_safe').remove();
292					return;
293				}
294
295				if ( $title.closest('.marquee-freezed').length ) {
296					return;
297				}
298
299				if ( $_title.hasClass('un-marquee') || $_title.hasClass('un-marquee-opposite') ) {
300					continuousTextMarquee();
301				}
302
303				if ( $_title.hasClass('un-marquee-scroll') || $_title.hasClass('un-marquee-scroll-opposite') ) {
304					runTextMarquee();
305				}
306
307			};
308
309			var marqueeResize = function(e){
310				if ( isInMenu ) {
311					return;
312				}
313				var tOut = 1000;
314				if ( isInMenu ) {
315						gsap.killTweensOf($title);
316						if ( typeof inview !== 'undefined' && inview !== null ) {
317							inview.destroy();
318						}
319						if ( typeof marqueeTL !== 'undefined' && marqueeTL !== null ) {
320							marqueeTL.kill();
321						}
322						first = true;
323						$(window).off(marqueeNS);
324						$(document).off(marqueeNS);
325						initTextMarquee();
326				} else {
327					clearRequestTimeout(marqueeCheckResize);
328					marqueeCheckResize = requestTimeout(function(){
329						if ( newW !== UNCODE.wwidth ) {
330							gsap.killTweensOf($title);
331							if ( typeof inview !== 'undefined' && inview !== null ) {
332								inview.destroy();
333							}
334							if ( typeof marqueeTL !== 'undefined' && marqueeTL !== null ) {
335								marqueeTL.kill();
336							}
337							first = true;
338							$(window).off(marqueeNS);
339							$(document).off(marqueeNS);
340							initTextMarquee();
341							newW = UNCODE.wwidth;
342						}
343					}, tOut);
344				}
345			};
346
347			$(window).off('resize', marqueeResize)
348			.on( 'resize', marqueeResize);
349			$(window).off('uncode.re-layout', marqueeResize)
350			.on( 'uncode.re-layout', marqueeResize);
351
352			cloneSpan($title, txt);
353
354			if ( $('body').hasClass('compose-mode') && typeof window.parent.vc !== 'undefined' ) {
355				window.parent.vc.events.on( 'shortcodeView:updated', function( e ){
356					var $_titles = $('.un-text-marquee',e.view.$el);
357					clearRequestTimeout(marqueeCheckResize);
358					marqueeCheckResize = requestTimeout(function(){
359						initTextMarquee($_titles);
360					}, 1000);
361				});
362			}
363		});
364
365		$(window).on( 'load wwResize', function(e) {
366			stableHeight = UNCODE.wheight;
367		});
368
369	};
370
371	document.addEventListener("DOMContentLoaded", function() {
372		if ( isInitMarque !== true ) {
373			initTextMarquee();
374		}
375	});
376
377	if ( document.fonts && document.fonts.ready && typeof document.fonts.ready.then === 'function' ) {
378		document.fonts.ready.then(function(){
379			initTextMarquee();
380		});
381	}
382
383	$(window).on('focus load resize',function(){
384		clearTimeout(initMarquee);
385		initMarquee = setTimeout(function(){
386			if ( isInitMarque !== true ) {
387				initTextMarquee();
388			}
389		}, 500);
390	});
391	
392	$(document).on('pumAfterOpen pumAfterClose', function(args){
393		initTextMarquee();
394	});
395
396	$(document).on('uncode-scrolltrigger-refresh', function(args){
397		var nextDocH = Math.round($(document).height());
398
399		if ( Math.abs(nextDocH - lastMarqueeDocH) <= 2 ) {
400			return;
401		}
402
403		lastMarqueeDocH = nextDocH;
404
405		clearRequestTimeout(marqueeCheckResize);
406
407		marqueeCheckResize = requestTimeout(function(){
408			initTextMarquee();
409		}, 250);
410	});
411};
412
413})(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.