Improve autoscroll behavior for text dragging
This commit is contained in:
parent
b7daccf9a9
commit
ddf5d1ab45
2 changed files with 7 additions and 5 deletions
|
|
@ -16,6 +16,7 @@
|
|||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: inherit;
|
||||
z-index: 8;
|
||||
}
|
||||
|
||||
.ace_content {
|
||||
|
|
|
|||
|
|
@ -193,16 +193,15 @@ function DragdropHandler(mouseHandler) {
|
|||
};
|
||||
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
|
||||
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
|
||||
var scrollX = 0;
|
||||
var scrollY = 0;
|
||||
var scrollCursor = {row: dragCursor.row, column: dragCursor.column};
|
||||
if (nearestXOffset / characterWidth <= 2) {
|
||||
scrollX = characterWidth * (offsets.x.left < offsets.x.right ? -1 : +1);
|
||||
scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
|
||||
}
|
||||
if (nearestYOffset / lineHeight <= 1) {
|
||||
scrollY = lineHeight * (offsets.y.top < offsets.y.bottom ? -1 : +1);
|
||||
scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
|
||||
}
|
||||
editor.moveCursorToPosition(dragCursor);
|
||||
editor.renderer.scrollBy(scrollX, scrollY);
|
||||
editor.renderer.scrollCursorIntoView(scrollCursor);
|
||||
}
|
||||
|
||||
function addDragMarker() {
|
||||
|
|
@ -220,7 +219,9 @@ function DragdropHandler(mouseHandler) {
|
|||
clearInterval(timerId);
|
||||
editor.session.removeMarker(dragSelectionMarker);
|
||||
dragSelectionMarker = null;
|
||||
editor.$blockScrolling += 1;
|
||||
editor.selection.fromOrientedRange(range);
|
||||
editor.$blockScrolling -= 1;
|
||||
range = null;
|
||||
counter = 0;
|
||||
event.removeListener(document, "mousemove", onMouseMove);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue