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;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
|
z-index: 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_content {
|
.ace_content {
|
||||||
|
|
|
||||||
|
|
@ -193,16 +193,15 @@ function DragdropHandler(mouseHandler) {
|
||||||
};
|
};
|
||||||
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
|
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
|
||||||
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
|
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
|
||||||
var scrollX = 0;
|
var scrollCursor = {row: dragCursor.row, column: dragCursor.column};
|
||||||
var scrollY = 0;
|
|
||||||
if (nearestXOffset / characterWidth <= 2) {
|
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) {
|
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.moveCursorToPosition(dragCursor);
|
||||||
editor.renderer.scrollBy(scrollX, scrollY);
|
editor.renderer.scrollCursorIntoView(scrollCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDragMarker() {
|
function addDragMarker() {
|
||||||
|
|
@ -220,7 +219,9 @@ function DragdropHandler(mouseHandler) {
|
||||||
clearInterval(timerId);
|
clearInterval(timerId);
|
||||||
editor.session.removeMarker(dragSelectionMarker);
|
editor.session.removeMarker(dragSelectionMarker);
|
||||||
dragSelectionMarker = null;
|
dragSelectionMarker = null;
|
||||||
|
editor.$blockScrolling += 1;
|
||||||
editor.selection.fromOrientedRange(range);
|
editor.selection.fromOrientedRange(range);
|
||||||
|
editor.$blockScrolling -= 1;
|
||||||
range = null;
|
range = null;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
event.removeListener(document, "mousemove", onMouseMove);
|
event.removeListener(document, "mousemove", onMouseMove);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue