HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/salamatk/takarzan.ir/wp-content/themes/xts-luman/js/scripts/stickyLoaderPosition.js
/* global xts_settings */
(function($) {
	XTSThemeModule.$document.on('xtsPjaxStart xtsPortfolioPjaxStart', function() {
		XTSThemeModule.stickyLoaderPosition();
	});

	XTSThemeModule.stickyLoaderPosition = function() {
		var loaderVerticalPosition = function() {
			var $products = $('.xts-products[data-source="main_loop"], .xts-portfolio-loop[data-source="main_loop"]');
			var $loader = $products.parent().find('.xts-sticky-loader');

			if ($products.length < 1) {
				return;
			}

			var offset = XTSThemeModule.$window.height() / 2;
			var scrollTop = XTSThemeModule.$window.scrollTop();
			var holderTop = $products.offset().top - offset + 45;
			var holderHeight = $products.height();
			var holderBottom = holderTop + holderHeight - 100;

			if (scrollTop < holderTop) {
				$loader.addClass('xts-position-top');
				$loader.removeClass('xts-position-stick');
			} else if (scrollTop > holderBottom) {
				$loader.addClass('xts-position-bottom');
				$loader.removeClass('xts-position-stick');
			} else {
				$loader.addClass('xts-position-stick');
				$loader.removeClass('xts-position-top xts-position-bottom');
			}
		};

		XTSThemeModule.$window.off('scroll.loaderVerticalPosition');

		XTSThemeModule.$window.on('scroll.loaderVerticalPosition', loaderVerticalPosition);
	};

	$(document).ready(function() {
		XTSThemeModule.stickyLoaderPosition();
	});
})(jQuery);