PageSourceSearch

https://welovetheplanet.com/wp-content/themes/ac-child/assets/js/wltp-motion.js?ver=1791464789

js welovetheplanet.com collected 2026-10-09 23:06:58 UTC 2,654 bytes, 65 lines download raw bytes

1/** Progressive WLTP motion: first-paint content is never hidden or rewritten. */
2(function () {
3	'use strict';
4	var reduced = window.matchMedia('(prefers-reduced-motion: reduce)');
5	if (reduced.matches || !document.body.classList.contains('ac-commerce')) return;
6	var targets = [];
7	var observer;
8	var hero = document.querySelector('.ac-hero-media-panel img');
9
10	function show(element) {
11		element.classList.remove('wltp-motion-pending');
12		if (observer) observer.unobserve(element);
13	}
14	function stop() {
15		if (observer) observer.disconnect();
16		targets.forEach(show);
17		if (hero) hero.classList.remove('wltp-motion-hero');
18	}
19
20	try {
21		if ('IntersectionObserver' in window) {
22			observer = new IntersectionObserver(function (entries) {
23				entries.forEach(function (entry) {
24					if (entry.isIntersecting) show(entry.target);
25				});
26			}, { threshold: 0.01 });
27			var selector = '.site-main .ac-shop-product-card-wrap, .site-main h2, .site-main h3, .site-main .ac-blog-kaart, .site-main .ac-media-image';
28			document.querySelectorAll(selector).forEach(function (element) {
29				// Never animate controls, nested card content, or content already seen.
30				if (element.closest('form, dialog, header, footer, .ac-hero-shell, .ac-hero-media-panel')) return;
31				if (element.parentElement.closest('.ac-shop-product-card-wrap, .ac-blog-kaart')) return;
32				if (element.getBoundingClientRect().top < window.innerHeight) return;
33				targets.push(element);
34				element.style.setProperty('--wltp-enter-delay', ((targets.length - 1) % 4) * 45 + 'ms');
35				element.classList.add('wltp-motion-item', 'wltp-motion-pending');
36				observer.observe(element);
37			});
38			document.addEventListener('focusin', function (event) {
39				var target = event.target && typeof event.target.closest === 'function'
40					? event.target.closest('.wltp-motion-item')
41					: null;
42				if (target) show(target);
43			});
44		}
45		if (hero) {
46			var zoom = function () {
47				// Two frames preserve a real scale(1) start even with a warm image cache.
48				window.requestAnimationFrame(function () {
49					window.requestAnimationFrame(function () {
50						if (!reduced.matches && hero.naturalWidth) hero.classList.add('wltp-motion-hero');
51					});
52				});
53			};
54			var ready = function () {
55				if (typeof hero.decode === 'function') hero.decode().then(zoom, zoom);
56				else zoom();
57			};
58			if (hero.complete && hero.naturalWidth) ready();
59			else hero.addEventListener('load', ready, { once: true });
60		}
61		reduced.addEventListener('change', function (event) { if (event.matches) stop(); });
62	} catch (error) {
63		stop(); // An unavailable observer or provider must never strand content.
64	}
65})();

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.