When you set overflow-y: scroll on an element, a scroll bar will appear
when the content overflows the available space. When that happens, you may want
to modify the scroll position yourself. For example, maybe you have a chat room
that autoscrolls as new messages come in. This module provides functions like
Dom.Scroll.toBottom that let you do that kind of thing.
Find the node with the given Id and scroll it to the bottom.
How much this element is scrolled vertically.
Say you have a node that does not fit in its container. A scroll bar shows up.
Initially you are at the top, which means y is 0. If you scroll down 300
pixels, y will be 300.
This is roughly the same as saying document.getElementById(id).scrollTop.
Set the vertical scroll to whatever offset you want.
Imagine you have a chat room and you want to control how it scrolls. Say the full chat is 400 pixels long, but it is in a box that limits the visible height to 100 pixels.
toY "chat" 0 it will scroll to the very top.toY "chat" 300 it will be at the bottom.If we provide values outside that range, they just get clamped, so
toY "chat" 900 is also scrolled to the bottom.
Find the node with the given Id and scroll it to the far left.
So toLeft id is the same as toX id 0.
Find the node with the given Id and scroll it to the far right.
How much this element is scrolled horizontally.
Say you have a node that does not fit in its container. A scroll bar shows up.
Initially you are at the far left, which means x is 0. If you scroll right
300 pixels, x will be 300.
This is roughly the same as saying document.getElementById(id).scrollLeft.
Set the horizontal scroll to whatever offset you want.
It works just like toY, so check out those docs for a more complete example.
Find the node with the given
Idand scroll it to the top.So
toTop idis the same astoY id 0.