Created
November 1, 2014 19:56
-
-
Save acarabott/97e8d68ac1cf3c822c44 to your computer and use it in GitHub Desktop.
Sublime Text 3 API, check if view scroll position is at bottom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useful for implementing output view auto scrolling, only when at the bottom | |
def view_is_at_bottom(view): | |
layout_h = view.layout_extent()[1] | |
view_h = view.viewport_extent()[1] | |
view_y = view.viewport_position()[1] | |
line_h = view.line_height() | |
view_taller_than_content = layout_h <= view_h | |
at_bottom_of_content = view_y + view_h >= layout_h - line_h | |
return view_taller_than_content or at_bottom_of_content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is actually quite slow, a less accurate but more efficient way is