PageSourceSearch

https://blackparakeetztoo.com/wp-content/themes/woodmart/js/scripts/global/lazyLoading.js?ver=7.3.1

js blackparakeetztoo.com collected 2026-10-08 08:10:06 UTC 4,235 bytes, 150 lines download raw bytes

1/* global woodmart_settings */
2(function($) {
3	woodmartThemeModule.$document.on('wdHiddenSidebarsInited', function() {
4		woodmartThemeModule.lazyLoading();
5	});
6
7	$.each([
8		'frontend/element_ready/wd_products.default',
9		'frontend/element_ready/wd_products_tabs.default',
10		'frontend/element_ready/wd_product_categories.default',
11		'frontend/element_ready/wd_products_brands.default',
12		'frontend/element_ready/wd_blog.default',
13		'frontend/element_ready/wd_images_gallery.default',
14		'frontend/element_ready/wd_product_categories.default',
15		'frontend/element_ready/wd_slider.default',
16		'frontend/element_ready/wd_banner_carousel.default',
17		'frontend/element_ready/wd_banner.default',
18		'frontend/element_ready/wd_infobox_carousel.default',
19		'frontend/element_ready/wd_infobox.default',
20		'frontend/element_ready/wd_instagram.default',
21		'frontend/element_ready/wd_testimonials.default'
22	], function(index, value) {
23		woodmartThemeModule.wdElementorAddAction(value, function() {
24			woodmartThemeModule.lazyLoading();
25		});
26	});
27
28	woodmartThemeModule.lazyLoading = function() {
29		if (!window.addEventListener || !window.requestAnimationFrame || !document.getElementsByClassName) {
30			return;
31		}
32
33		var pItem = document.getElementsByClassName('wd-lazy-load'), pCount, timer;
34
35		woodmartThemeModule.$document.on('wood-images-loaded added_to_cart updated_checkout', function() {
36			inView();
37		});
38
39		// Fix for menu.
40		woodmartThemeModule.$body.on('click', '.wd-header-mobile-nav > a, .wd-nav-opener, .wd-btn-show-cat', function() {
41			woodmartThemeModule.$document.trigger('wood-images-loaded');
42		});
43
44		$('.wd-scroll-content').on('scroll', function() {
45			woodmartThemeModule.$document.trigger('wood-images-loaded');
46		});
47
48		// WooCommerce tabs fix
49		$('.wc-tabs > li').on('click', function() {
50			woodmartThemeModule.$document.trigger('wood-images-loaded');
51		});
52
53		// scroll and resize events
54		window.addEventListener('scroll', scroller, false);
55		window.addEventListener('resize', scroller, false);
56
57		// DOM mutation observer
58		if (MutationObserver) {
59			var observer = new MutationObserver(function() {
60				if (pItem.length !== pCount) {
61					inView();
62				}
63			});
64
65			observer.observe(document.body, {
66				subtree      : true,
67				childList    : true,
68				attributes   : true,
69				characterData: true
70			});
71		}
72
73		// initial check
74		inView();
75
76		// throttled scroll/resize
77		function scroller() {
78			timer = timer || setTimeout(function() {
79				timer = null;
80				inView();
81			}, 100);
82		}
83
84		// image in view?
85		function inView() {
86			if (pItem.length) {
87				requestAnimationFrame(function() {
88					var offset = parseInt(woodmart_settings.lazy_loading_offset);
89					var wT = window.pageYOffset, wB = wT + window.innerHeight + offset, cRect, pT, pB, p = 0;
90
91					while (p < pItem.length) {
92						cRect = pItem[p].getBoundingClientRect();
93						pT = wT + cRect.top;
94						pB = pT + cRect.height;
95
96						if (wT < pB && wB > pT && !pItem[p].loaded) {
97							loadFullImage(pItem[p], p);
98						} else {
99							p++;
100						}
101					}
102
103					pCount = pItem.length;
104				});
105			}
106		}
107
108		// replace with full image
109		function loadFullImage(item) {
110			item.onload = addedImg;
111
112			if (item.querySelector('img') !== null) {
113				item.querySelector('img').onload = addedImg;
114				item.querySelector('img').src = item.dataset.woodSrc;
115				item.querySelector('source').srcset = item.dataset.woodSrc;
116
117				if (typeof (item.dataset.srcset) != 'undefined') {
118					item.querySelector('img').srcset = item.dataset.srcset;
119				}
120			}
121
122			item.src = item.dataset.woodSrc;
123			if (typeof (item.dataset.srcset) != 'undefined') {
124				item.srcset = item.dataset.srcset;
125			}
126
127			item.loaded = true;
128
129			// replace image
130			function addedImg() {
131				requestAnimationFrame(function() {
132					item.classList.add('wd-loaded');
133
134					var $masonry = jQuery(item).parents('.view-masonry .gallery-images, .grid-masonry, .masonry-container');
135					if ($masonry.length > 0) {
136						$masonry.isotope('layout');
137					}
138					var $categories = jQuery(item).parents('.categories-masonry');
139					if ($categories.length > 0) {
140						$categories.packery();
141					}
142				});
143			}
144		}
145	};
146
147	$(document).ready(function() {
148		woodmartThemeModule.lazyLoading();
149	});
150})(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.