Fix undragged handle position not being updated during drag scroll

This commit is contained in:
Kovid Goyal 2020-08-09 09:46:34 +05:30
parent 08105adbc8
commit 2bedd3bfb2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -550,8 +550,12 @@ class SelectionBar:
self.set_handle_colors() self.set_handle_colors()
if self.state is DRAGGING: if self.state is DRAGGING:
self.show() self.show()
# needed for drag scrolling
self.position_undragged_handle()
return return
if self.state is EDITING: if self.state is EDITING:
self.left_handle.style.display = 'none'
self.right_handle.style.display = 'none'
self.show() self.show()
self.place_editor() self.place_editor()
return return
@ -619,10 +623,7 @@ class SelectionBar:
if changed.left?: if changed.left?:
bar.style.left = changed.left + 'px' bar.style.left = changed.left + 'px'
def place_single_handle(self, handle_height, handle, boundary, is_left):
def position_handles(self, left_handle, right_handle, start, end):
def place_single_handle(handle, boundary, is_left):
s = handle.style s = handle.style
s.display = 'block' if boundary.onscreen else 'none' s.display = 'block' if boundary.onscreen else 'none'
height = handle_height * 3 height = handle_height * 3
@ -639,9 +640,24 @@ class SelectionBar:
s.left = boundary.x + 'px' s.left = boundary.x + 'px'
self.right_line_height = boundary.height self.right_line_height = boundary.height
def position_handles(self, left_handle, right_handle, start, end):
handle_height = max(start.height, end.height) handle_height = max(start.height, end.height)
place_single_handle(left_handle, start, True) self.place_single_handle(handle_height, left_handle, start, True)
place_single_handle(right_handle, end, False) self.place_single_handle(handle_height, right_handle, end, False)
def position_undragged_handle(self):
cs = self.view.currently_showing.selection
start, end = map_boundaries(cs)
handle_height = max(start.height, end.height)
if self.dragging_handle is self.left_handle_id:
handle = self.right_handle
boundary = end
is_left = False
else:
handle = self.left_handle
boundary = start
is_left = True
self.place_single_handle(handle_height, handle, boundary, is_left)
# }}} # }}}
# Editor {{{ # Editor {{{