標籤:自動 eval 取資料 非同步 swipe var 視窗 事件 dex
網頁滾動模式
//滾到到底部自動拉取資料 //頁面滾到底部非同步載入下一頁資料 $(window).scroll(function () { //已經滾動到上面的頁面高度 var scrollTop = parseFloat($(this).scrollTop()), //頁面高度 scrollHeight = $(document).height(), //瀏覽器視窗高度 windowHeight = parseFloat($(this).height()), totalHeight = scrollTop + windowHeight; //此處是捲軸到底部時候觸發的事件,在這裡寫要載入的資料,或者是拉動捲軸的操作 if (scrollTop + windowHeight >= scrollHeight - 0.7) { var index = $(‘.swiper-slide-active‘).data("index"); var id = $(‘.swiper-slide-active‘).attr("id"); eval(‘‘+id+‘(‘+Number(index)+1+‘,‘+pageNumber+‘,"‘+userid+‘")‘); } });可滾動的元素 ,滾動到底部,觸發擷取資料
//滾到到底部自動拉取資料 //頁面滾到底部非同步載入下一頁資料 $(".swiper-slide").scroll(function () { //已經滾動到上面的頁面高度 var scrollTop = parseFloat($(this).scrollTop()), //滾動高度 scrollHeight = this.scrollHeight, //視窗高度 windowHeight = $(this).height(), totalHeight = scrollTop + windowHeight; //此處是捲軸到底部時候觸發的事件,在這裡寫要載入的資料,或者是拉動捲軸的操作 if (scrollTop + windowHeight >= scrollHeight - 0.7) { console.log("==="); var nextIndex = Number($(‘.swiper-slide-active‘).data("index"))+1; var id = $(‘.swiper-slide-active‘).attr("id"); eval(‘‘ + id + ‘(‘ + nextIndex + ‘,‘ + pageNumber + ‘,"‘ + userid + ‘")‘); } });
網頁滾動到底部,拉取資料