HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/viitorx.stgviitor.com/wp-content/themes/viitorx/js/content-blocks-reveal.js
/**
 * Adds scroll-triggered fades to paragraphs and block-level divs inside article prose.
 *
 * Targets: blog #blog-article-body.entry-content, .case-study-rich, legacy .cs-container.
 */
(function () {
	'use strict';

	var CLASS_ROOT = 'viitorx-inline-reveal';
	var CLASS_VISIBLE = CLASS_ROOT + '--visible';

	function prefersReducedMotion() {
		return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
	}

	function markVisible(el) {
		el.classList.add(CLASS_VISIBLE);
	}

	function shouldSkip(el) {
		return (
			el.closest('nav.page-links') ||
			el.classList.contains('screen-reader-text') ||
			el.closest('#blog-single-toc') ||
			el.closest('#blog-toc-empty')
		);
	}

	/** Skip loose <p> if it lives under root > div … (tier-1 wrappers animate as a whole). */
	function paragraphWrappedByTierOneDiv(root, p) {
		var n = p.parentElement;
		while (n && n !== root) {
			if (n.parentElement === root && n.tagName === 'DIV') {
				return true;
			}
			n = n.parentElement;
		}
		return false;
	}

	function ingestRoot(root, uniqPush) {
		root.querySelectorAll('p').forEach(function (p) {
			if (!paragraphWrappedByTierOneDiv(root, p)) uniqPush(p);
		});
		Array.prototype.forEach.call(root.children, function (el) {
			if (el.tagName === 'DIV') uniqPush(el);
		});
	}

	function collectElements() {
		var out = [];
		var weakOk = typeof WeakSet !== 'undefined';
		var seen = weakOk ? new WeakSet() : [];

		function uniqPush(el) {
			if (!el || el.nodeType !== 1 || shouldSkip(el)) {
				return;
			}
			if (weakOk) {
				if (seen.has(el)) return;
				seen.add(el);
			} else {
				for (var i = 0; i < seen.length; i++) {
					if (seen[i] === el) return;
				}
				seen.push(el);
			}
			out.push(el);
		}

		document.querySelectorAll('.viitorx-blog-single-page #blog-article-body.entry-content').forEach(function (root) {
			ingestRoot(root, uniqPush);
		});

		document.querySelectorAll('.single-case-study .case-study-rich').forEach(function (root) {
			ingestRoot(root, uniqPush);
		});

		document.querySelectorAll('.single-case-study div.cs-container').forEach(function (root) {
			ingestRoot(root, uniqPush);
		});

		return out;
	}

	function bindReveal(nodes) {
		if (!nodes.length) return;

		if (typeof ScrollTrigger !== 'undefined') {
			nodes.forEach(function (el) {
				ScrollTrigger.create({
					trigger: el,
					start: 'top 96%',
					once: true,
					onEnter: function () {
						markVisible(el);
					},
				});
			});
			requestAnimationFrame(function () {
				if (typeof ScrollTrigger !== 'undefined' && ScrollTrigger.refresh) {
					ScrollTrigger.refresh();
				}
			});
			return;
		}

		if ('IntersectionObserver' in window) {
			var io = new IntersectionObserver(
				function (entries) {
					entries.forEach(function (entry) {
						if (!entry.isIntersecting) return;
						markVisible(entry.target);
						io.unobserve(entry.target);
					});
				},
				{ root: null, rootMargin: '0px 0px 22% 0px', threshold: 0 }
			);
			nodes.forEach(function (el) {
				io.observe(el);
			});
			return;
		}

		nodes.forEach(markVisible);
	}

	function init() {
		var nodes = collectElements();
		if (!nodes.length) return;
		if (prefersReducedMotion()) return;

		nodes.forEach(function (el) {
			el.classList.add(CLASS_ROOT);
		});
		bindReveal(nodes);
	}

	if (document.readyState === 'loading') {
		document.addEventListener('DOMContentLoaded', init);
	} else {
		init();
	}
})();