feat: implement dynamic knowledge graph updates and state management services
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
export function initObserver(dotNetHelper, containerSelector, itemSelector) {
|
||||
const options = {
|
||||
root: null,
|
||||
rootMargin: '0px',
|
||||
threshold: 0.6 // 60% of the block must be visible
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
const id = entry.target.id;
|
||||
const content = entry.target.innerText;
|
||||
dotNetHelper.invokeMethodAsync('HandleBlockReached', id, content);
|
||||
}
|
||||
});
|
||||
}, options);
|
||||
|
||||
const items = document.querySelectorAll(itemSelector);
|
||||
items.forEach(item => observer.observe(item));
|
||||
|
||||
return observer;
|
||||
}
|
||||
Reference in New Issue
Block a user