I am trying to find which function is causing the page to scroll when hovering an element, but so far I got nothing.
There is no specific listener attached to the element, from what I could understand it is triggered via a mouseover
listener or similar, the elements contain lots of listeners attached to them.
Also this is not a browser function, it is specific to javascript because it doesn't occur when I null the majority of the code.
I already tried to null
ing the scroll methods I know of like so:
[
'scroll',
'scrollTo',
'scrollBy',
'scrollByLines',
'scrollByPages',
'scrollX',
'scrollY',
'scrollMaxX',
'scrollMaxY',
'scrollHeight',
'scrollIntoView',
'scrollTop',
'scrollTopMax'
].forEach(function(a) {
window[a] = null;
document.documentElement[a] = null;
})
Hoping that when the mysterious function tried to call the scroll method it would throw an error, but instead it still scrolls normally without any problems.
I also tried listening to the scroll event, but no returned argument brings me closer to the responsible function.
I have tried looking for it in the minified source code, but the common scroll
search returns 266 results and I am not even sure if it is using a typical scroll method.
Is there any way that I can locate the function that is making the page scroll?
If you want to check whether the user has scrolled to the bottom of the page, you can use the scroll() jQuery event. The given code piece takes the top scroll of the window, so how much the page is scrolled down, it adds the height of the visible window and checks if it is equivalent to the height of the document.
To get or set the scroll position of an element, you follow these steps: First, select the element using the selecting methods such as querySelector() . Second, access the scroll position of the element via the scrollLeft and scrollTop properties.
To detect if a user is scrolling with JavaScript, we can watch for scroll events by adding event handlers. to add the userHasScrolled variable. Then we set the window. onscroll property to a function that runs when we scroll.
In 2020, go to Chrome's Dev Tools, Sources
tab, and on the right pane, scroll to the very bottom to find Event Listener Breakpoints
.
There you'll find scroll
inside the Control
group. Clicking on the checkbox will stop execution (it's a breakpoint) whenever the scroll event is fired, and you'll be able to trace the code who did it in the same pane (right side), under the Call Stack
group (it's probably the first group in the right pane after debugger kicks in).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With