I am using window.scroll
function, but window.scrollTop
didn't return any value in lightning controller. Help me.
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);
});
},
You have a typo: 3rd row - latScrollTop instead of lastScrollTop.
Fixed Code: