![]() ![]() ![]() The reason it's a problem is directly related with the behaviour of the scroll event - how often it fires.Įssentially, all events that fire at high rates, such as touch, scroll, mousemove, keydown, will compromise the performance of an application when tiring processes are carried on in their handlers.Īs you know, the scroll event can potentially occur at each pixel you scroll (on touch devices) on a document. The scrollTop property can only navigate the caller object's own scrollbar to the provided value - if it ain't has any scrollbar then the assignment won't simply work. This is because the scrollbar that the browser renders for the document belongs to the element, NOT to the element. In simpler words, to move the document to a given scroll offset we can use something like = scrollOffset Now it maybe tempting to think that since window.onscroll is analogous to i.e both point to the same handler, we can use these properties on document.body to scroll the HTML document. This is because window isn't an element, and as we stated above, these scroll properties are only available on element objects. The same idea can also be applied to the main HTML document, however with certain wierd things.įirst of all, the scrollTop and scrollLeft properties are not available on window. ![]() In the link given above, we execute the statement div.scrollTop = 50 on the click of a button, so that you can easily visualise the change! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |