actionscript 3 - Flex 3: Determine if scroll panel child is visible -


let's have canvas fixed height , vertical scroll bar. , canvas has 10 children in vertical line (like vbox) combined height exceeds height of canvas. based on scroll bar position, of children visible @ time.

is possible determine children visible? or whether or not specific child visible on screen?

i’m not sure on timeliness of answer, had similar question , following code worked me:

if (item.y < container.verticalscrollposition || item.y + item.height - container.verticalscrollposition > container.height) {       // item not (completely) visible  } 

basically checking against following criteria:

1) item’s y position above container’s current vertical scroll position (i.e. outside of container’s top boundary)?

2) item’s bottom position scrolled outside of container’s bottom boundary? calculated using item’s bottom position (i.e. item’s y position plus height) minus current vertical scroll position.

if want check of items in container, you’d have loop through , check each against these criteria. throw above code in function , return whether item visible or not. there might better/cleaner way, haven’t found 1 yet.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -