MCPcopy Index your code
hub / github.com/Fiddle-Digital/string-scroll / onMutationObserver

Method onMutationObserver

src/index.ts:391–451  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

389 this.sEn.onWheel(e)
390 }
391 private onMutationObserver() {
392 const observer = new MutationObserver((mutations) => {
393 mutations.forEach((mutation) => {
394 if (mutation.type === "childList") {
395 let isResizing = false
396 if (mutation.removedNodes.length > 0) {
397
398 mutation.removedNodes.forEach(removedNode => {
399
400 if (removedNode.nodeType === Node.ELEMENT_NODE) {
401 if ((removedNode as Element).getAttribute('data-string-fixed') == null) {
402 isResizing = true
403 } else {
404
405 }
406 this.animations.forEach((animation) => {
407 Array.from(animation.allObjects).map(([name, value]) => {
408 if(document.body.contains(value.el) == false){
409 animation.removeObject(value.id)
410 }
411 });
412 })
413 }
414 })
415 if (isResizing) {
416 this.onResize()
417 }
418 }
419 if (mutation.addedNodes.length > 0) {
420 mutation.addedNodes.forEach(addedNode => {
421 if (addedNode.nodeType === Node.ELEMENT_NODE) {
422 if ((addedNode as Element).getAttribute('data-string-fixed') == null) {
423 isResizing = true
424 } else {
425 }
426 }
427 })
428
429
430 this.animations.forEach((animation) => {
431 let elements = document.querySelectorAll(`[${animation.key}]:not([data-string-connect]):not([${animation.key}-inited])`)
432 elements.forEach(element => {
433 animation.addObject(element)
434 });
435 });
436 if (isResizing) {
437 this.onResize()
438 }
439 }
440
441 }
442 });
443 });
444 const config = {
445 attributes: true,
446 childList: true,
447 subtree: true
448 };

Callers 1

startMethod · 0.95

Calls 3

onResizeMethod · 0.95
removeObjectMethod · 0.80
addObjectMethod · 0.80

Tested by

no test coverage detected