2016-12-22 57 views
0

我正在使用window.scroll函數,但window.scrollTop沒有在雷電控制器中返回任何值。幫我。我的window.scrolltop不能正常工作

initialize : function(component, event, helper) { 
      var isHidden = false 
      var lastScrollTop = 0 
      console.log('heyyyyyy'); 
      window.addEventListener('scroll', function() { 
       console.log('heyasasyyyyy'); 
       var scrollTop = document.documentElement.scrollTop; 
       var offset = scrollTop-lastScrollTop ; 
       lastScrollTop = scrollTop ; 
       console.log(scrollTop+'++++'+offset+'++++++'+lastScrollTop); 
      }); 

     }, 

回答

0

你有一個錯字:第3排 - latScrollTop,而不是拉小號 tScrollTop。

固定碼:

initialize : function(component, event, helper) { 
      var isHidden = false 
      var lastScrollTop = 0 
      console.log('heyyyyyy'); 
      window.addEventListener('scroll', function() { 
       console.log('heyasasyyyyy'); 
       var scrollTop = document.documentElement.scrollTop; 
       var offset = scrollTop-lastScrollTop ; 
       lastScrollTop = scrollTop ; 
       console.log(scrollTop+'++++'+offset+'++++++'+lastScrollTop); 
      }); 

     },