Added support for edge detection

Added support for checking if the top or bottom edge is within the viewport.