J
John Geddes
Has anyone come up with an "IsInview" function that one could use to
test whether scrollIntoView is needed?
Imagine a (scrolled) list of editable item prices. I want to impose
maximum and minimum limits - so I test the just-changed value when the
user either starts to edit another field, or tries to close the form.
If there is an error, I need to highlight the error - and that means
scrolling back to the problem item if it is not in view. Simple enough.
BUT if the item is ALREADY in view, I don't want to do a scrollIntoView
because that will move the item to the top or bottom of the scrollable
area (depending on the parameter setting) - when the item is already
happily displayed within the visible area. The user would see the list
move when there is no need to do anything other than highlight the field
as problematic.
But how to test whether a particular element is currently "in view"? Ideas?
John Geddes
England
test whether scrollIntoView is needed?
Imagine a (scrolled) list of editable item prices. I want to impose
maximum and minimum limits - so I test the just-changed value when the
user either starts to edit another field, or tries to close the form.
If there is an error, I need to highlight the error - and that means
scrolling back to the problem item if it is not in view. Simple enough.
BUT if the item is ALREADY in view, I don't want to do a scrollIntoView
because that will move the item to the top or bottom of the scrollable
area (depending on the parameter setting) - when the item is already
happily displayed within the visible area. The user would see the list
move when there is no need to do anything other than highlight the field
as problematic.
But how to test whether a particular element is currently "in view"? Ideas?
John Geddes
England