var Testarr = []
var prevscroll = 0
var cache = 0
Scrollfunction(e) {varthat = This; vary =E.detail.scrolltop; //calculate only within a region if(Y > Testarr[0] && y < testarr[testarr.length-1]) { // Down if(Y >=prevscroll) { //TODO: Cache the current zone, varDown = (function(x) {if(y >= testarr[x] && y < testarr[x + 1]) {Console.log (' Down ', ' abcdefghjklmnpqrstwxyz '. Split (') [x]) cache=x}Else { ++x; Down (x); } }); Down (cache); // up}Else { //TODO: Cache the current zone varUp = (function(x) {//if the current is 0 or the current scroll is greater than the current, then the necessary action if(x = = 0 | | y >= testarr[x])return false; //If the scrollbar is up, then it is definitely smaller than the current + + (next). //The main is to judge, whether less than the current, if less than the current, the explanation to take the current-(prev) if(Y <Testarr[x]) {Console.log (' Up ', ' abcdefghjklmnpqrstwxyz '. Split (') [x-1]) Cache= X-1 } }); Up (cache); }} Prevscroll=y}
What Ghost algorithm?