Mixin which scrolls a container to ensure that a newly-selected item is visible to the user.
When the selected item in a list-like component changes, it's easier for the to confirm that the selection has changed to an appropriate item if the user can actually see that item.
This mixin expects a selectedItem
property to be set when the selection
changes. You can supply that yourself, or use the
ItemsSelection mixin.
Kind: global class
- SelectionInView
- .scrollItemIntoView(item)
- .scrollTarget :
HTMLElement
Scroll the given element completely into view, minimizing the degree of scrolling performed.
Blink has a scrollIntoViewIfNeeded()
function that does something
similar, but unfortunately it's non-standard, and in any event often ends
up scrolling more than is absolutely necessary.
Kind: instance method of SelectionInView
Param | Type | Description |
---|---|---|
item | HTMLElement |
the item to scroll into view. |
The element that should be scrolled to bring an item into view.
The default value of this property is the element itself.
Kind: instance property of SelectionInView