Fixed vertical modal rendering to always display within browser viewport

Referencing Issue #3 , I have fixed the top rendering so that the modal is always displayed within browser viewport
You can use the value of `diff` in the `if` condition directly (`diff > 0`) instead of recomputing it.