mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Keep current cursor or top line in view when resizing Console to avoid losing user context (#13695) (#13710)
* keep current cursor or top line in view when resizing to avoid losing user context * rename variable to more descriptive name * move state from editor to smart_resize
This commit is contained in:
parent
889fbe92a8
commit
6436a1f566
2 changed files with 15 additions and 3 deletions
|
@ -24,6 +24,8 @@ module.exports = function (input, output) {
|
|||
$resizer.addClass('active');
|
||||
var startWidth = $left.width();
|
||||
var startX = event.pageX;
|
||||
input.resize.topRow = input.renderer.layerConfig.firstRow;
|
||||
output.resize.topRow = output.renderer.layerConfig.firstRow;
|
||||
|
||||
function onMove(event) {
|
||||
setEditorWidth(startWidth + event.pageX - startX)
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
import { throttle } from 'lodash';
|
||||
import { get, throttle } from 'lodash';
|
||||
|
||||
module.exports = function (editor) {
|
||||
const resize = editor.resize;
|
||||
return throttle(() => resize.call(editor), 35)
|
||||
};
|
||||
const throttledResize = throttle(() => {
|
||||
|
||||
resize.call(editor);
|
||||
|
||||
// Keep current top line in view when resizing to avoid losing user context
|
||||
let userRow = get(throttledResize, 'topRow', 0);
|
||||
if (userRow !== 0) {
|
||||
editor.renderer.scrollToLine(userRow, false, false, () => {});
|
||||
}
|
||||
}, 35);
|
||||
return throttledResize;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue