Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
peach-html5-editor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1a3115b
)
cursor into view: allow to go top/bottom of doc
author
Jason Woofenden
<jason@jasonwoof.com>
Wed, 30 Mar 2016 13:45:42 +0000
(09:45 -0400)
committer
Jason Woofenden
<jason@jasonwoof.com>
Wed, 30 Mar 2016 13:45:42 +0000
(09:45 -0400)
editor.coffee
patch
|
blob
|
history
diff --git
a/editor.coffee
b/editor.coffee
index
c78151a
..
ef5d3a2
100644
(file)
--- a/
editor.coffee
+++ b/
editor.coffee
@@
-1095,32
+1095,36
@@
class PeachHTML5Editor
move_cursor_into_view: (y_target) ->
return if y_target is @cursor.y
was = @cursor
move_cursor_into_view: (y_target) ->
return if y_target is @cursor.y
was = @cursor
- y_min = @wrap2.scrollTop + breathing_room
- y_max = @wrap2.scrollTop + @wrap2_height - 2 * breathing_room
+ y_min = @wrap2.scrollTop
+ unless @wrap2.scrollTop is 0
+ y_min += breathing_room
+ y_max = @wrap2.scrollTop + @wrap2_height
+ unless @wrap2.scrollTop is @wrap2.scrollHeight - @wrap2_height # downmost
+ y_max -= breathing_room
y_target = Math.min y_target, y_max
y_target = Math.max y_target, y_min
if y_target < @cursor.y
finder = find_up_cursor_position
y_target = Math.min y_target, y_max
y_target = Math.max y_target, y_min
if y_target < @cursor.y
finder = find_up_cursor_position
- far_enough = (a, b) ->
- return a <= b
+ far_enough = (cur, target_y) ->
+ return cur.y + cur.h <= target_y
else
finder = find_down_cursor_position
else
finder = find_down_cursor_position
- far_enough = (a, b) ->
- return a >= b
+ far_enough = (cur, y_target) ->
+ return cur.y >= y_target
loop
cur = finder @tree, was, @cursor_ideal_x
break unless cur?
loop
cur = finder @tree, was, @cursor_ideal_x
break unless cur?
- break if far_enough cur.y, y_target
+ break if far_enough cur, y_target
was = cur
if was is @cursor
was = null
if was?
was = cur
if was is @cursor
was = null
if was?
- if was.y > y_max
+ if was.y + was.h > y_max
was = null
else if was.y < y_min
was = null
if cur?
was = null
else if was.y < y_min
was = null
if cur?
- if cur.y > y_max
+ if cur.y + cur.h > y_max
cur = null
else if cur.y < y_min
cur = null
cur = null
else if cur.y < y_min
cur = null
@@
-1128,7
+1132,7
@@
class PeachHTML5Editor
# both valid, pick best
if cur.y < y_min
new_cursor = was
# both valid, pick best
if cur.y < y_min
new_cursor = was
- else if was.y > y_max
+ else if was.y + was.h > y_max
new_cursor = cur
else if cur.y - y_target < y_target - was.y
new_cursor = cur
new_cursor = cur
else if cur.y - y_target < y_target - was.y
new_cursor = cur