Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger an on scroll event without scrolling

my Question is, how can i trigger (simulate or something esle) an on scroll event. In my special case I don't want to load all the Conservations in LinkedIn by scolling down all conservations, because there are too many!

I do not need a PHP or Javascript solution. Simply using dev-tools at chrome is enough to get my goal.

like image 534
CTSchmidt Avatar asked Mar 08 '16 22:03

CTSchmidt


People also ask

Does scrollIntoView trigger scroll event?

scrollIntoView does not trigger mousewheel nor scroll event in Angular. Bookmark this question.

How do you load the webpage content based on user scrolling?

You can use window. addeventlistener to track the scrolling behavior the webpage and load more content to the page when the user is at the foot of the webpage. document. documentElement.

How does Onscroll work?

Definition and Usage. The onscroll event occurs when an element's scrollbar is being scrolled. Tip: use the CSS overflow style property to create a scrollbar for an element.


1 Answers

Alternatively, you can manually trigger a real scroll event as following:

el.dispatchEvent(new CustomEvent('scroll')) 

Which feels a bit less of a hack (and more performant) than dual scrolling by +1 and -1 pixels...

This should run any piece of code listening for a scroll event.

Edit: To support IE11 or other legacy browser, consider using a CustomEvent polyfill such as mdn-polyfills

like image 143
Pandaiolo Avatar answered Sep 22 '22 21:09

Pandaiolo