∅:D[
2.185] → [
3.224:1302]
B:BD[
3.224] → [
3.224:1302]
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
print('cursor', cursor_y, 'dvpx')
if Viewport.y < node.y then
-- node starts within Viewport
print('node starts within viewport')
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
if cursor_y > max_cursor_y then
-- set Viewport.y so cursor_y == max_cursor_y
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
-- solve for Viewport.y
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
print('adjusting Viewport to', Viewport.y)
end
else
-- node extends above Viewport
print('node extends above viewport')
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
print('screen top', screen_top_y, 'dvpx')
local min_screen_top_y = cursor_y + safety_margin - App.screen.height
if screen_top_y < min_screen_top_y then
screen_top_y = min_screen_top_y
Viewport.y = node.y + screen_top_y/Viewport.zoom
print('adjusting Viewport to', Viewport.y)
local cursor_y = y_of_schema1(node.editor, node.editor.cursor1)
print('cursor', cursor_y, 'dvpx')
if Viewport.y < node.y then
-- node starts within Viewport
print('node starts within viewport')
local max_cursor_y = App.screen.height - scale(node.y - Viewport.y) - safety_margin
if cursor_y > max_cursor_y then
-- set Viewport.y so cursor_y == max_cursor_y
-- equation: cursor_y == App.screen.height - (node.y - Viewport.y)*Viewport.zoom - safety_margin
-- solve for Viewport.y
Viewport.y = node.y - (App.screen.height - cursor_y - safety_margin)/Viewport.zoom
print('adjusting Viewport to', Viewport.y)
end
else
-- node extends above Viewport
print('node extends above viewport')
local screen_top_y = y_of_schema1(node.editor, node.editor.screen_top1)
print('screen top', screen_top_y, 'dvpx')
local min_screen_top_y = cursor_y + safety_margin - App.screen.height
if screen_top_y < min_screen_top_y then
screen_top_y = min_screen_top_y
Viewport.y = node.y + screen_top_y/Viewport.zoom
print('adjusting Viewport to', Viewport.y)
end