X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=editor.coffee;h=a0bd0a41d48864e6120bf7c2bfa90d4b56de99b8;hb=5de51db974972ef00b21121b7472075c0222b551;hp=ef5d3a2bb575ef89dd8dbabc6fe28bc596405d83;hpb=d6b9400fe66b74ce333003c8ab1940ef163aa684;p=peach-html5-editor.git diff --git a/editor.coffee b/editor.coffee index ef5d3a2..a0bd0a4 100644 --- a/editor.coffee +++ b/editor.coffee @@ -1077,6 +1077,13 @@ class PeachHTML5Editor @kill_cursor() return on_page_up_key: (e) -> + if @wrap2.scrollTop is 0 + return unless @cursor? + new_cursor = first_cursor_position @tree + if new_cursor? + if new_cursor.n isnt @cursor.n or new_cursor.i isnt @cursor.i + @move_cursor new_cursor + return if @cursor? screen_y = @cursor.y - @wrap2.scrollTop scroll_amount = @wrap2_height - breathing_room @@ -1084,10 +1091,17 @@ class PeachHTML5Editor if @cursor? @move_cursor_into_view screen_y + @wrap2.scrollTop on_page_down_key: (e) -> + lowest_scrollpos = @wrap2.scrollHeight - @wrap2_height + if @wrap2.scrollTop is lowest_scrollpos + return unless @cursor? + new_cursor = last_cursor_position @tree + if new_cursor? + if new_cursor.n isnt @cursor.n or new_cursor.i isnt @cursor.i + @move_cursor new_cursor + return if @cursor? screen_y = @cursor.y - @wrap2.scrollTop scroll_amount = @wrap2_height - breathing_room - lowest_scrollpos = @wrap2.scrollHeight - @wrap2_height @wrap2.scrollTop = Math.min lowest_scrollpos, @wrap2.scrollTop + scroll_amount if @cursor? @move_cursor_into_view screen_y + @wrap2.scrollTop