Scroll Event not working in mobile browsers

Hi, I have been developing my portfolio. On Scroll,I change the navbar background color and display an arrow button clicking on which takes you to the top of the page. It works fine in desktop browsers, but not in mobile browsers. Can you help me out? This is my portfolio - https://brindhavenkatesan92.github.io/

Could you share your code?

This is the code I have used. Hiding and displaying the downarrow and changing the navbar background on scroll. It is working well in desktop browsers, but not in mobile browsers

	var alternavbar = function(){
		var scrollTop =  window.scrollY;
		if( scrollTop > 50 ){
			navigatr.classList.remove('transparent');
			$(downarrow).fadeIn();
		}else{
			navigatr.classList.add('transparent');
			$(downarrow).fadeOut();
		}
	}
	alternavbar();
	window.addEventListener('scroll', alternavbar);

Which mobile browser are you trying?

I tested in Chrome and Safari…

Try changing scrollY to pageYOffset.

I changed it but still it hasn’t come. Have I missed any file?:thinking:

At the top of your function, add document.title = window.scrollY

var alternavbar = function(){
                document.title = window.scrollY
		var scrollTop =  window.scrollY;
		if( scrollTop > 50 ){
			navigatr.classList.remove('transparent');
			$(downarrow).fadeIn();
		}else{
			navigatr.classList.add('transparent');
			$(downarrow).fadeOut();
		}
	}
	alternavbar();
	window.addEventListener('scroll', alternavbar);