JS 모 바 일 엔 드 로 딩, 드 롭 다운 리 셋

5216 단어 JS
기록 해 봐. 
let this_ = this;
        //    
        document.getElementById("news_list").addEventListener('scroll', (e) => {
            //console.log(e);
            let wScrollY = document.getElementById("news_list").scrollTop; //        
            let wInnerH = document.getElementById("news_list").offsetHeight; //            (   )
            let bScrollH = document.getElementById("news_list").scrollHeight; //       
            //console.info(wScrollY+" - "+wInnerH+" - "+bScrollH);
            if (wScrollY + wInnerH >= bScrollH) {
                $(".periodNews").hide();
                $(".loadMore").show();
                /*
                          
                    this_.findNews("", "up", "");
                */
                
                //      1   ,       
                window.setTimeout(function () {
                    $(".loadMore").hide();
                    $(".periodNews").show();
                }, 1000)
            }
        }, true);
        let startY = 0;
        let endY = 0;
        //    
        $(".newsListDiv").on({
            touchmove: function (event) {//      
                //console.info(event);
                let touch = event.targetTouches[0];
                //endX = touch.pageX;
                endY = touch.pageY;
                if (startY == 0) {//     
                    startY = endY;
                }
                let wScrollY = document.getElementById("news_list").scrollTop; //        
                if (wScrollY == 0 && (endY - startY) > 2) {//        0,             ,       
                    //console.info("    ");
                    $(".loadMoreTop").show();//        
                    $(".refresh").show();//  ‘    ’  
                    let height = endY - startY;//       
                    if (height > 92) {//          
                        $(".refresh").hide();//  ‘    ’  
                        $(".refreshWait").show();//  ‘    ’  
                        height = 92;
                    }
                    //$(".loadMoreTop").stop();
                    $(".loadMoreTop").animate({height: height + "px"}, 0);//  
                }

            },
            touchend: function () {//      
                if ((endY - startY) > 90) {//        50   ,     
                    $(".refreshWait").hide();
                    //$(".refresh").hide();
                    $(".refreshing").show();
                    /*
                              
                        this_.findNews("", "down", "");
                    */
                
                    //      1   ,       
                    window.setTimeout(function(){
                     $(".loadMoreTop").animate({height:"0px"},50);//    
                     $(".refreshing").hide();
                     $(".refresh").show();
                    },1000)
                } else {
                    $(".loadMoreTop").animate({height: "0px"}, 50);
                }
                startY = 0;
                endY = 0;
            }
        });
    //    
    async findNews(type, refreshType?, title?) {
        if (!type || type == "  ") {
            type = '';
        }
        if (!refreshType || refreshType == "down") {//  
            this.pageStart = 0;
            this.pageEnd = 10;
        } else if (refreshType == "up") {//  
            this.pageStart = this.pageEnd;
            this.pageEnd += 10;
        }
        //  
        let data = {
            type: type,
            n: this.pageStart,
            m: this.pageEnd,
            title: title || ''
        }
        let url = "";

        const result = await this.http.ajax(url, data);
        //            
        if (refreshType && refreshType == "up") {
            this.news = this.news.concat(result);
        } else {
            this.news = result;
        }
        if (refreshType) {
            if (refreshType == "down") {//  
                $(".loadMoreTop").animate({height: "0px"}, 50);//    
                $(".refreshing").hide();
                $(".refresh").show();
            } else {//  
                $(".loadMore").hide();
                $(".periodNews").show();
            }
        }

    }
...
...
_(:з」∠)_

 
아마 자줏빛 이 될 거 야.

좋은 웹페이지 즐겨찾기