Doing the code that link the page scroll movement to the Posts Slider i've fall into this:
https://developer.mozilla.org/en-US/doc ... server_API
then i changed the way i had think to code the task and abandoned the old way that was using this function:Implementing intersection detection in the past involved event handlers and loops calling methods like Element.getBoundingClientRect() to build up the needed information for every element affected. Since all this code runs on the main thread, even one of these can cause performance problems. When a site is loaded with these tests, things can get downright ugly.
Code: Select all
function w3vv_isScrolledIntoView(el) {
//console.log('testme ' + isVisible);
var rect = el.getBoundingClientRect();
var elemTop = rect.top;
var elemBottom = rect.bottom;
// Only completely visible elements return true:
//var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
// Partially visible elements return true, in this way:
var isVisible = elemTop < window.innerHeight && elemBottom >= 0;
//console.log('isVisible ' + isVisible);
return isVisible;
} // END // w3vv_isScrolledIntoView()
The same way will be re-coded the Vertical Views extension, abandoning the old way in favor of the Intersection_Observer_API and so to make it lighter. As can be viewed into the raw example, the scroll, as is the behavior of the actual Vertical Views, stop when the limit of pages tabs are reached. It is perfectly congruent based on how it is actually coded.
But it will be modified to scroll until the End or the Start of the topic and not to stop where there are ellipsis.
The use of the Intersection_Observer_API and more things i noted during this time, will make the code much more easy removing some complex and heavy loops that become not useful.
The Element.getBoundingClientRect() will still be used for the Posts Slider snippet, where the computation is done in a very light way and works fine, with the use of it for few known elements, which data are computed only once because the element dimension never change.
It is not anymore good for different and heavy tasks, such detecting if elements are or not into the viewport while scrolling a page and that maybe add elements into the DOM while the user is scrolling.