1class VirtualList { 2 constructor(objRef, id) { 3 this.objRef = objRef; 4 this.initIntersectionObserver(id); 5 } 6 7 initIntersectionObserver(id) { 8 if (this.observer) { 9 this.dispose(); 10 } 11 12 this.element = document.getElementById(id); 13 if (this.element != null) { 14 this.children = Array.from(this.element.querySelectorAll('.virtual-item')); 15 this.visibleItems = new Set(); 16 const options = { 17 threshold: 0.1 18 }; 19 20 this.observer = new IntersectionObserver(this.handleIntersect.bind(this), options); 21 this.children.forEach((child, index) => { 22 child.dataset.index = index; 23 this.observer.observe(child) 24 }); 25 } 26 } 27 28 handleIntersect(entries) { 29 entries.forEach(entry => { 30 const index = parseInt(entry.target.dataset.index); 31 32 if (entry.isIntersecting) { 33 this.visibleItems.add(index); 34 } 35 else { 36 this.visibleItems.delete(index); 37 } 38 }); 39 40 clearTimeout(this.debounceTimeout); 41 this.debounceTimeout = setTimeout(() => { 42 this.objRef.invokeMethodAsync('UpdateVisibleItems', Array.from(this.visibleItems)); 43 }, 150); 44 } 45 46 dispose() { 47 if (this.observer) { 48 this.observer.disconnect(); 49 this.observer = null; 50 } 51 52 if (this.debounceTimeout) { 53 clearTimeout(this.debounceTimeout); 54 this.debounceTimeout = null; 55 } 56 57 this.visibleItems.clear(); 58 this.children = null; 59 this.element = null; 60 } 61} 62 63window.InitializeVirtualList = function(objRef, id) { 64 const list = new VirtualList(objRef, id); 65 window.virtualLists[id] = list; 66} 67 68window.UpdateVirtualList = function(id) { 69 window.virtualLists[id].initIntersectionObserver(id); 70} 71 72window.DisposeVirtualList = function(id) { 73 if (window.virtualLists[id]) { 74 window.virtualLists[id].dispose(); 75 window.virtualLists[id].objRef = null; 76 delete window.virtualLists[id]; 77 } 78} 79 80window.virtualLists = {};
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.