If I pass a NodeListOf<HTMLElement> to the InView function, is an Intersection Observer created for each Element or is a general one created? #3054
-
I am working with the InView function to detect different elements inside the ViewPort, so I am currently giving it a NodeListOf.
I have this question to know if it is a better idea to pass each element with a forEach or leave it this way. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Each inView() makes just one observer per call, no matter how many elements are passed. By contrast, useInView and whileInView make theoretically minimum number of observers across all calls - at some point I’d like to bring this further optimisation to inView() but that depends on how much extra filesize it brings and if it’s worth it. |
Beta Was this translation helpful? Give feedback.
Each inView() makes just one observer per call, no matter how many elements are passed. By contrast, useInView and whileInView make theoretically minimum number of observers across all calls - at some point I’d like to bring this further optimisation to inView() but that depends on how much extra filesize it brings and if it’s worth it.